X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffg_menu.c;h=d44c6f422e2623ec8dc73823997fffd58e84b5e1;hb=c21722a39780abcd692cb01978fbf57fc7d06a45;hp=9b40bfef8e0f6002f5f43906c1145f81108c9c1e;hpb=d2e9a9aa23fe843257ac6826d38d9fbb8b9f6e5f;p=freeglut diff --git a/src/fg_menu.c b/src/fg_menu.c index 9b40bfe..d44c6f4 100644 --- a/src/fg_menu.c +++ b/src/fg_menu.c @@ -667,10 +667,18 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed, ( window->Menu[ button ] ) && pressed ) { - /* XXX Posting a requisite Redisplay seems bogus. */ - window->State.Redisplay = GL_TRUE; - fghActivateMenu( window, button ); - return GL_TRUE; + /* If mouseclick was outside the parent window, ignore. This can + * happen when another mouse button is already depressed and the + * window thus has mouse capture + */ + if (window->State.MouseX>0 && window->State.MouseY>0 && + window->State.MouseXState.Width && window->State.MouseXState.Height) + { + /* XXX Posting a requisite Redisplay seems bogus. */ + window->State.Redisplay = GL_TRUE; + fghActivateMenu( window, button ); + return GL_TRUE; + } } return GL_FALSE; @@ -679,6 +687,7 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed, /* * Deactivates a menu pointed by the function argument. */ +static SFG_Menu* menuDeactivating = NULL; void fgDeactivateMenu( SFG_Window *window ) { SFG_Window *parent_window = NULL; @@ -690,6 +699,10 @@ void fgDeactivateMenu( SFG_Window *window ) /* Check if there is an active menu attached to this window... */ menu = window->ActiveMenu; freeglut_return_if_fail( menu ); + /* Check if we are already deactivating this menu, abort in that case (glutHideWindow below can cause this function to be called again on the same menu..) */ + if (menu==menuDeactivating) + return; + menuDeactivating = menu; parent_window = menu->ParentWindow; @@ -717,6 +730,8 @@ void fgDeactivateMenu( SFG_Window *window ) if( menuEntry->SubMenu ) fghDeactivateSubMenu( menuEntry ); } + /* Done deactivating menu */ + menuDeactivating = NULL; fgSetWindow ( parent_window ) ; @@ -791,7 +806,7 @@ void fghCalculateMenuBoxSize( void ) /* * Creates a new menu object, adding it to the freeglut structure */ -int FGAPIENTRY glutCreateMenu( void(* callback)( int ) ) +int FGAPIENTRY glutCreateMenu( FGCBMenu callback ) { /* The menu object creation code resides in freeglut_structure.c */ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateMenu" );