From 2822fb448bf8ebc2a07fac999d07d1ea522e9964 Mon Sep 17 00:00:00 2001 From: Diederick Niehorster 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: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1535 7f0cb862-5218-0410-a997-914c9d46530a --- progs/demos/CallbackMaker/CallbackMaker.c | 7 +++++-- src/fg_callbacks.c | 7 +++++++ src/mswin/fg_main_mswin.c | 9 +++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/progs/demos/CallbackMaker/CallbackMaker.c b/progs/demos/CallbackMaker/CallbackMaker.c index 1b41b0e..771a6cd 100644 --- a/progs/demos/CallbackMaker/CallbackMaker.c +++ b/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/src/fg_callbacks.c b/src/fg_callbacks.c index 01b256e..e60ea66 100644 --- a/src/fg_callbacks.c +++ b/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/src/mswin/fg_main_mswin.c b/src/mswin/fg_main_mswin.c index bf02a7e..f00728e 100644 --- a/src/mswin/fg_main_mswin.c +++ b/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; -- 1.7.10.4