These change a bunch of assignments to calls to set the current window correctly, and also (possibly) fixes most of the remaining menu problem. - John Fay

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@174 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
puggles 2003-08-29 18:10:06 +00:00
parent c27c9a8631
commit 652e30fcb9
3 changed files with 132 additions and 32 deletions

View File

@ -106,6 +106,8 @@ static void fghReshapeWindowByHandle
( HWND handle, int width, int height ) ( HWND handle, int width, int height )
#endif #endif
{ {
SFG_Window *current_window = fgStructure.Window ;
/* /*
* Find the window that received the reshape event * Find the window that received the reshape event
*/ */
@ -142,6 +144,12 @@ static void fghReshapeWindowByHandle
* we resize the window. * we resize the window.
*/ */
window->State.Redisplay = TRUE ; window->State.Redisplay = TRUE ;
/*
* If this is a menu, restore the active window
*/
if ( window->IsMenu )
fgSetWindow ( current_window ) ;
} }
/* /*
@ -157,6 +165,8 @@ static void fghcbDisplayWindow( SFG_Window *window, SFG_Enumerator *enumerator )
(window->State.Redisplay == TRUE) && (window->State.Redisplay == TRUE) &&
(window->State.Visible == TRUE) ) (window->State.Visible == TRUE) )
{ {
SFG_Window *current_window = fgStructure.Window ;
/* /*
* OKi, this is the case: have the window set as the current one * OKi, this is the case: have the window set as the current one
*/ */
@ -171,6 +181,8 @@ static void fghcbDisplayWindow( SFG_Window *window, SFG_Enumerator *enumerator )
* And execute the display callback immediately after * And execute the display callback immediately after
*/ */
window->Callbacks.Display(); window->Callbacks.Display();
fgSetWindow ( current_window ) ;
} }
#elif TARGET_HOST_WIN32 #elif TARGET_HOST_WIN32
@ -180,6 +192,8 @@ static void fghcbDisplayWindow( SFG_Window *window, SFG_Enumerator *enumerator )
*/ */
if( window->State.NeedToResize ) if( window->State.NeedToResize )
{ {
SFG_Window *current_window = fgStructure.Window ;
fgSetWindow( window ); fgSetWindow( window );
fghReshapeWindowByHandle( fghReshapeWindowByHandle(
@ -192,6 +206,8 @@ static void fghcbDisplayWindow( SFG_Window *window, SFG_Enumerator *enumerator )
* Never ever do that again: * Never ever do that again:
*/ */
window->State.NeedToResize = FALSE; window->State.NeedToResize = FALSE;
fgSetWindow ( current_window ) ;
} }
/* /*
@ -616,6 +632,11 @@ void FGAPIENTRY glutMainLoopEvent( void )
*/ */
if( window->Callbacks.Entry != NULL ) if( window->Callbacks.Entry != NULL )
{ {
/*
* Set the current window
*/
fgSetWindow ( window ) ;
/* /*
* Yeah. Notify the window about having the mouse cursor over * Yeah. Notify the window about having the mouse cursor over
*/ */
@ -636,6 +657,11 @@ void FGAPIENTRY glutMainLoopEvent( void )
*/ */
if( window->Callbacks.Entry != NULL ) if( window->Callbacks.Entry != NULL )
{ {
/*
* Set the current window
*/
fgSetWindow ( window ) ;
/* /*
* Yeah. Notify the window about having the mouse cursor over * Yeah. Notify the window about having the mouse cursor over
*/ */
@ -659,7 +685,12 @@ void FGAPIENTRY glutMainLoopEvent( void )
/* /*
* Let's make the window redraw as a result of the mouse motion. * Let's make the window redraw as a result of the mouse motion.
*/ */
if ( window->IsMenu ) window->State.Redisplay = TRUE ; window->State.Redisplay = TRUE ;
/*
* Since the window is a menu, make the parent window current
*/
fgSetWindow ( window->ActiveMenu->ParentWindow ) ;
break; break;
} }
@ -680,7 +711,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
/* /*
* Set the current window * Set the current window
*/ */
fgStructure.Window = window ; fgSetWindow ( window ) ;
/* /*
* Yup. Have it executed immediately * Yup. Have it executed immediately
@ -698,7 +729,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
/* /*
* Set the current window * Set the current window
*/ */
fgStructure.Window = window ; fgSetWindow ( window ) ;
/* /*
* That's right, and there is a passive callback, too. * That's right, and there is a passive callback, too.
@ -778,6 +809,11 @@ void FGAPIENTRY glutMainLoopEvent( void )
if ( pressed == TRUE ) fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ; if ( pressed == TRUE ) fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
} }
/*
* Let's make the window redraw as a result of the mouse click and menu activity.
*/
window->State.Redisplay = TRUE ;
break ; break ;
} }
@ -786,6 +822,11 @@ void FGAPIENTRY glutMainLoopEvent( void )
*/ */
if ( ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) ) if ( ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) )
{ {
/*
* Let's make the window redraw as a result of the mouse click.
*/
window->State.Redisplay = TRUE ;
/* /*
* Set the current window * Set the current window
*/ */
@ -802,13 +843,13 @@ void FGAPIENTRY glutMainLoopEvent( void )
/* /*
* Check if there is a mouse callback hooked to the window * Check if there is a mouse callback hooked to the window
*/ */
if( fgStructure.Window->Callbacks.Mouse == NULL ) if( window->Callbacks.Mouse == NULL )
break; break;
/* /*
* Set the current window * Set the current window
*/ */
fgSetWindow( window ); fgSetWindow ( window );
/* /*
* Remember the current modifiers state * Remember the current modifiers state
@ -876,11 +917,6 @@ void FGAPIENTRY glutMainLoopEvent( void )
*/ */
len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode), &keySym, &composeStatus ); len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode), &keySym, &composeStatus );
/*
* Get ready to calling the keyboard/special callbacks
*/
fgSetWindow( window );
/* /*
* GLUT API tells us to have two separate callbacks... * GLUT API tells us to have two separate callbacks...
*/ */
@ -891,6 +927,11 @@ void FGAPIENTRY glutMainLoopEvent( void )
*/ */
if( keyboard_cb != NULL ) if( keyboard_cb != NULL )
{ {
/*
* Set the current window
*/
fgSetWindow( window );
/* /*
* Remember the current modifiers state * Remember the current modifiers state
*/ */
@ -965,6 +1006,11 @@ void FGAPIENTRY glutMainLoopEvent( void )
*/ */
if( (special_cb != NULL) && (special != -1) ) if( (special_cb != NULL) && (special != -1) )
{ {
/*
* Set the current window
*/
fgSetWindow( window );
/* /*
* Remember the current modifiers state * Remember the current modifiers state
*/ */
@ -1005,7 +1051,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
/* /*
* No messages in the queue, which means we are idling... * No messages in the queue, which means we are idling...
*/ */
if ( fgState.IdleCallback != NULL ) if( fgState.IdleCallback != NULL )
fgState.IdleCallback(); fgState.IdleCallback();
/* /*
@ -1051,7 +1097,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
/* /*
* No messages in the queue, which means we are idling... * No messages in the queue, which means we are idling...
*/ */
if ( fgState.IdleCallback != NULL ) if( fgState.IdleCallback != NULL )
fgState.IdleCallback(); fgState.IdleCallback();
/* /*
@ -1094,8 +1140,22 @@ void FGAPIENTRY glutMainLoop( void )
while ( window != NULL ) while ( window != NULL )
{ {
if ( window->Callbacks.Visibility != NULL ) if ( window->Callbacks.Visibility != NULL )
{
SFG_Window *current_window = fgStructure.Window ;
/*
* Set the current window
*/
fgSetWindow( window );
window->Callbacks.Visibility ( window->State.Visible ) ; window->Callbacks.Visibility ( window->State.Visible ) ;
/*
* Restore the current window
*/
fgSetWindow( current_window );
}
window = (SFG_Window *)window->Node.Next ; window = (SFG_Window *)window->Node.Next ;
} }
#endif #endif
@ -1383,7 +1443,12 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
/* /*
* Let's make the window redraw as a result of the mouse motion. * Let's make the window redraw as a result of the mouse motion.
*/ */
if ( window->IsMenu ) window->State.Redisplay = TRUE ; window->State.Redisplay = TRUE ;
/*
* Since the window is a menu, make the parent window current
*/
fgSetWindow ( window->ActiveMenu->ParentWindow ) ;
break; break;
} }
@ -1520,6 +1585,11 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
if ( pressed == TRUE ) fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ; if ( pressed == TRUE ) fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
} }
/*
* Let's make the window redraw as a result of the mouse click and menu activity.
*/
if ( ! window->IsMenu ) window->State.Redisplay = TRUE ;
break ; break ;
} }
@ -1528,6 +1598,11 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
*/ */
if ( ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) ) if ( ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) )
{ {
/*
* Let's make the window redraw as a result of the mouse click.
*/
window->State.Redisplay = TRUE ;
/* /*
* Set the current window * Set the current window
*/ */
@ -1544,13 +1619,13 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
/* /*
* Check if there is a mouse callback hooked to the window * Check if there is a mouse callback hooked to the window
*/ */
if( fgStructure.Window->Callbacks.Mouse == NULL ) if( window->Callbacks.Mouse == NULL )
break; break;
/* /*
* Set the current window * Set the current window
*/ */
fgSetWindow( window ); fgSetWindow ( window );
/* /*
* Remember the current modifiers state. * Remember the current modifiers state.
@ -1563,7 +1638,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
/* /*
* Finally execute the mouse callback * Finally execute the mouse callback
*/ */
fgStructure.Window->Callbacks.Mouse( window->Callbacks.Mouse(
button, button,
pressed == TRUE ? GLUT_DOWN : GLUT_UP, pressed == TRUE ? GLUT_DOWN : GLUT_UP,
window->State.MouseX, window->State.MouseX,
@ -1589,11 +1664,6 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) ) if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
break; break;
/*
* Set the current window
*/
fgSetWindow( window );
/* /*
* Remember the current modifiers state. This is done here in order * Remember the current modifiers state. This is done here in order
* to make sure the VK_DELETE keyboard callback is executed properly. * to make sure the VK_DELETE keyboard callback is executed properly.
@ -1642,14 +1712,22 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
* The delete key should be treated as an ASCII keypress: * The delete key should be treated as an ASCII keypress:
*/ */
if( window->Callbacks.Keyboard != NULL ) if( window->Callbacks.Keyboard != NULL )
{
fgSetWindow( window );
window->Callbacks.Keyboard( 127, window->State.MouseX, window->State.MouseY ); window->Callbacks.Keyboard( 127, window->State.MouseX, window->State.MouseY );
} }
}
/* /*
* Execute the special callback, if present, given the conversion was a success: * Execute the special callback, if present, given the conversion was a success:
*/ */
if( (keypress != -1) && (window->Callbacks.Special != NULL) ) if( (keypress != -1) && (window->Callbacks.Special != NULL) )
{ {
/*
* Set the current window
*/
fgSetWindow( window );
/* /*
* Have the special callback executed: * Have the special callback executed:
*/ */
@ -1669,11 +1747,6 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
int keypress = -1; int keypress = -1;
POINT mouse_pos ; POINT mouse_pos ;
/*
* Set the current window
*/
fgSetWindow( window );
/* /*
* Remember the current modifiers state. This is done here in order * Remember the current modifiers state. This is done here in order
* to make sure the VK_DELETE keyboard callback is executed properly. * to make sure the VK_DELETE keyboard callback is executed properly.
@ -1721,7 +1794,10 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
* The delete key should be treated as an ASCII keypress: * The delete key should be treated as an ASCII keypress:
*/ */
if( window->Callbacks.KeyboardUp != NULL ) if( window->Callbacks.KeyboardUp != NULL )
{
fgSetWindow ( window ) ;
window->Callbacks.KeyboardUp( 127, window->State.MouseX, window->State.MouseY ); window->Callbacks.KeyboardUp( 127, window->State.MouseX, window->State.MouseY );
}
break ; break ;
default: default:
@ -1738,15 +1814,27 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
wParam=code[ 0 ]; wParam=code[ 0 ];
if( window->Callbacks.KeyboardUp != NULL ) if( window->Callbacks.KeyboardUp != NULL )
{
/*
* Set the current window
*/
fgSetWindow( window );
window->Callbacks.KeyboardUp( (char)wParam, window->State.MouseX, window->State.MouseY ); window->Callbacks.KeyboardUp( (char)wParam, window->State.MouseX, window->State.MouseY );
} }
} }
}
/* /*
* Execute the special callback, if present, given the conversion was a success: * Execute the special callback, if present, given the conversion was a success:
*/ */
if( (keypress != -1) && (window->Callbacks.SpecialUp != NULL) ) if( (keypress != -1) && (window->Callbacks.SpecialUp != NULL) )
{ {
/*
* Set the current window
*/
fgSetWindow( window );
/* /*
* Have the special callback executed: * Have the special callback executed:
*/ */
@ -1774,6 +1862,11 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
*/ */
if( window->Callbacks.Keyboard != NULL ) if( window->Callbacks.Keyboard != NULL )
{ {
/*
* Set the current window
*/
fgSetWindow( window );
/* /*
* Remember the current modifiers state * Remember the current modifiers state
*/ */
@ -1797,7 +1890,14 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
case WM_CAPTURECHANGED : /* User has finished resizing the window, force a redraw */ case WM_CAPTURECHANGED : /* User has finished resizing the window, force a redraw */
if ( window->Callbacks.Display ) if ( window->Callbacks.Display )
{
/*
* Set the current window
*/
fgSetWindow( window );
window->Callbacks.Display () ; window->Callbacks.Display () ;
}
/* lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ) ; */ /* lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ) ; */
break ; break ;

View File

@ -594,7 +594,7 @@ void fgDeactivateMenu( SFG_Window *window )
fgDeactivateSubMenu ( menuEntry ) ; fgDeactivateSubMenu ( menuEntry ) ;
} }
fgStructure.Window = current_window ; fgSetWindow ( current_window ) ;
} }
/* /*
@ -629,7 +629,7 @@ void fgDeactivateSubMenu( SFG_MenuEntry *menuEntry )
fgDeactivateSubMenu ( subMenuIter ) ; fgDeactivateSubMenu ( subMenuIter ) ;
} }
fgStructure.Window = current_window ; fgSetWindow ( current_window ) ;
} }
/* /*

View File

@ -168,7 +168,7 @@ SFG_Menu* fgCreateMenu( FGCBmenu menuCallback )
fgState.BuildingAMenu = FALSE ; fgState.BuildingAMenu = FALSE ;
glutHideWindow () ; /* Hide the window for now */ glutHideWindow () ; /* Hide the window for now */
fgStructure.Window = current_window ; fgSetWindow ( current_window ) ;
/* /*
* Initialize the object properties: * Initialize the object properties:
@ -296,9 +296,9 @@ void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
if ( window->Callbacks.Destroy != NULL ) if ( window->Callbacks.Destroy != NULL )
{ {
SFG_Window *activeWindow = fgStructure.Window ; SFG_Window *activeWindow = fgStructure.Window ;
fgStructure.Window = window ; fgSetWindow ( window ) ;
window->Callbacks.Destroy () ; window->Callbacks.Destroy () ;
fgStructure.Window = activeWindow ; fgSetWindow ( activeWindow ) ;
} }
/* /*