From f46574e2630f345d330b5587f65eec097fa90678 Mon Sep 17 00:00:00 2001 From: dcnieho Date: Fri, 1 Mar 2013 03:08:05 +0000 Subject: [PATCH] library should call window status func at all times, translation to visibility callback happens if needed. Documented this, and added notes on visibility/windowstatus func in callbackmaker demo git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1535 7f0cb862-5218-0410-a997-914c9d46530a --- .../freeglut/progs/demos/CallbackMaker/CallbackMaker.c | 7 +++++-- freeglut/freeglut/src/fg_callbacks.c | 7 +++++++ freeglut/freeglut/src/mswin/fg_main_mswin.c | 9 +++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c b/freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c index 1b41b0e..771a6cd 100644 --- a/freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c +++ b/freeglut/freeglut/progs/demos/CallbackMaker/CallbackMaker.c @@ -576,7 +576,6 @@ static void SetWindowCallbacks( int first ) glutPositionFunc( Position ); glutKeyboardFunc( Key ); glutSpecialFunc( Special ); - glutVisibilityFunc( Visibility ); glutKeyboardUpFunc( KeyUp ); glutSpecialUpFunc( SpecialUp ); if (first) @@ -588,7 +587,6 @@ static void SetWindowCallbacks( int first ) glutEntryFunc ( Entry ) ; glutCloseFunc ( Close ) ; glutOverlayDisplayFunc ( OverlayDisplay ) ; - glutWindowStatusFunc ( WindowStatus ) ; glutSpaceballMotionFunc ( SpaceMotion ) ; glutSpaceballRotateFunc ( SpaceRotation ) ; glutSpaceballButtonFunc ( SpaceButton ) ; @@ -596,6 +594,11 @@ static void SetWindowCallbacks( int first ) glutDialsFunc ( Dials ) ; glutTabletMotionFunc ( TabletMotion ) ; glutTabletButtonFunc ( TabletButton ) ; + /* glutVisibilityFunc is deprecated in favor of glutWindowStatusFunc, which provides more detail. + * Setting one of these overwrites the other (see docs). + */ + glutVisibilityFunc ( Visibility ); /* This will thus never be called, as glutWindowStatusFunc is set afterwards */ + glutWindowStatusFunc ( WindowStatus ) ; } int diff --git a/freeglut/freeglut/src/fg_callbacks.c b/freeglut/freeglut/src/fg_callbacks.c index 01b256e..e60ea66 100644 --- a/freeglut/freeglut/src/fg_callbacks.c +++ b/freeglut/freeglut/src/fg_callbacks.c @@ -165,6 +165,13 @@ void FGAPIENTRY glutDisplayFunc( FGCBDisplay callback ) /* * Sets the Visibility callback for the current window. + * NB: the Visibility func is deprecated in favor of the WindowStatus func, + * which provides more detail. The visibility func callback is implemented + * as a translation step from the windowStatus func. When the user sets the + * windowStatus func, any visibility func is overwritten. + * DEVELOPER NOTE: in the library, only invoke the window status func, this + * gets automatically translated to the visibility func if thats what the + * user has set. */ static void fghVisibility( int status ) { diff --git a/freeglut/freeglut/src/mswin/fg_main_mswin.c b/freeglut/freeglut/src/mswin/fg_main_mswin.c index bf02a7e..f00728e 100644 --- a/freeglut/freeglut/src/mswin/fg_main_mswin.c +++ b/freeglut/freeglut/src/mswin/fg_main_mswin.c @@ -143,11 +143,11 @@ void fgPlatformMainLoopPreliminaryWork ( void ) */ while( window ) { - if ( FETCH_WCB( *window, Visibility ) ) + if ( FETCH_WCB( *window, WindowStatus ) ) { SFG_Window *current_window = fgStructure.CurrentWindow ; - INVOKE_WCB( *window, Visibility, ( window->State.Visible ) ); + INVOKE_WCB( *window, WindowStatus, ( window->State.Visible?GLUT_FULLY_RETAINED:GLUT_HIDDEN ) ); fgSetWindow( current_window ); } @@ -872,8 +872,9 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR if (!lParam || !fgWindowByHandle((HWND)lParam)) /* Capture released or capture taken by non-FreeGLUT window */ setCaptureActive = 0; - /* User has finished resizing the window, force a redraw */ - INVOKE_WCB( *window, Display, ( ) ); + /* Docs advise a redraw */ + InvalidateRect( hWnd, NULL, GL_FALSE ); + UpdateWindow(hWnd); lRet = 0; /* Per docs, should return zero */ break;