X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffg_menu.c;h=65ec6741be5beff0fc74cb9fc7a1a38d7d0b19b1;hb=84bbdfc8e7dfb2e220a4d155159be91e88ea9433;hp=0e219b8bf21aaf2e1c95440eaac79bee362537f3;hpb=1b5ee849ba61b667aeba474a7e03406196478bee;p=freeglut diff --git a/src/fg_menu.c b/src/fg_menu.c index 0e219b8..65ec674 100644 --- a/src/fg_menu.c +++ b/src/fg_menu.c @@ -29,6 +29,7 @@ #include #include "fg_internal.h" + /* -- DEFINITIONS ---------------------------------------------------------- */ /* @@ -403,7 +404,7 @@ static void fghDisplayMenuBox( SFG_Menu* menu ) /* * Private static function to set the parent window of a submenu and all - * of its submenus + * of its submenus. */ static void fghSetMenuParentWindow( SFG_Window *window, SFG_Menu *menu ) { @@ -512,9 +513,9 @@ static void fghActivateMenu( SFG_Window* window, int button ) SFG_Menu* menu = window->Menu[ button ]; SFG_Window* current_window = fgStructure.CurrentWindow; - /* If the menu is already active in another window, deactivate it there */ + /* If the menu is already active in another window, deactivate it (and any submenus) there */ if ( menu->ParentWindow ) - menu->ParentWindow->ActiveMenu = NULL ; + fgDeactivateMenu(menu->ParentWindow); /* Mark the menu as active, so that it gets displayed: */ window->ActiveMenu = menu; @@ -620,11 +621,12 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed, /* * Outside the menu, deactivate if it's a downclick * - * XXX This isn't enough. A downclick outside of - * XXX the interior of our freeglut windows should also - * XXX deactivate the menu. This is more complicated. + * A downclick outside of the interior of our freeglut windows + * is dealt with in the WM_KILLFOCUS handler of fgPlatformWindowProc */ + { fgDeactivateMenu( window->ActiveMenu->ParentWindow ); + } /* * XXX Why does an active menu require a redisplay at @@ -659,12 +661,13 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed, void fgDeactivateMenu( SFG_Window *window ) { SFG_Window *parent_window = NULL; - - /* Check if there is an active menu attached to this window... */ - SFG_Menu* menu = window->ActiveMenu; + SFG_Menu* menu; SFG_MenuEntry *menuEntry; /* Did we find an active window? */ + freeglut_return_if_fail( window ); + /* Check if there is an active menu attached to this window... */ + menu = window->ActiveMenu; freeglut_return_if_fail( menu ); parent_window = menu->ParentWindow; @@ -689,7 +692,7 @@ void fgDeactivateMenu( SFG_Window *window ) { menuEntry->IsActive = GL_FALSE; - /* Is that an active submenu by any case? */ + /* Is that an active submenu by any chance? */ if( menuEntry->SubMenu ) fghDeactivateSubMenu( menuEntry ); }