is_handled = GL_TRUE;
}
- else if ( fgStructure.Menus.First ) /* Don't have to check whether this was a downpress or an uppress, there is no way to get an uppress in another window before a downpress... */
+ else if ( fgState.ActiveMenus ) /* Don't have to check whether this was a downpress or an uppress, there is no way to get an uppress in another window before a downpress... */
{
/* if another window than the one clicked in has an open menu, close it */
SFG_Menu *menu = fgGetActiveMenu();
{
/* The menu object creation code resides in freeglut_structure.c */
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateMenu" );
- if (fgGetActiveMenu())
+ if (fgState.ActiveMenus)
fgError("Menu manipulation not allowed while menus in use.");
return fgCreateMenu( callback )->ID;
menu = fgMenuByID( menuID );
freeglut_return_if_fail( menu );
- if (fgGetActiveMenu())
+ if (fgState.ActiveMenus)
fgError("Menu manipulation not allowed while menus in use.");
/* The menu object destruction code resides in freeglut_structure.c */
menuEntry = (SFG_MenuEntry *)calloc( sizeof(SFG_MenuEntry), 1 );
freeglut_return_if_fail( fgStructure.CurrentMenu );
- if (fgGetActiveMenu())
+ if (fgState.ActiveMenus)
fgError("Menu manipulation not allowed while menus in use.");
menuEntry->Text = strdup( label );
subMenu = fgMenuByID( subMenuID );
freeglut_return_if_fail( fgStructure.CurrentMenu );
- if (fgGetActiveMenu())
+ if (fgState.ActiveMenus)
fgError("Menu manipulation not allowed while menus in use.");
freeglut_return_if_fail( subMenu );
menu = fgMenuByID( menuID );
freeglut_return_if_fail( menu );
- if (fgGetActiveMenu())
+ if (fgState.ActiveMenus)
fgError("Menu manipulation not allowed while menus in use.");
font = fghFontByID( fontID );
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutChangeToMenuEntry" );
freeglut_return_if_fail( fgStructure.CurrentMenu );
- if (fgGetActiveMenu())
+ if (fgState.ActiveMenus)
fgError("Menu manipulation not allowed while menus in use.");
/* Get n-th menu entry in the current menu, starting from one: */
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutChangeToSubMenu" );
freeglut_return_if_fail( fgStructure.CurrentMenu );
- if (fgGetActiveMenu())
+ if (fgState.ActiveMenus)
fgError("Menu manipulation not allowed while menus in use.");
/* Get handle to sub menu */
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutRemoveMenuItem" );
freeglut_return_if_fail( fgStructure.CurrentMenu );
- if (fgGetActiveMenu())
+ if (fgState.ActiveMenus)
fgError("Menu manipulation not allowed while menus in use.");
/* Get n-th menu entry in the current menu, starting from one: */
freeglut_return_if_fail( fgStructure.CurrentWindow );
freeglut_return_if_fail( fgStructure.CurrentMenu );
- if (fgGetActiveMenu())
+ if (fgState.ActiveMenus)
fgError("Menu manipulation not allowed while menus in use.");
freeglut_return_if_fail( button >= 0 );
freeglut_return_if_fail( fgStructure.CurrentWindow );
freeglut_return_if_fail( fgStructure.CurrentMenu );
- if (fgGetActiveMenu())
+ if (fgState.ActiveMenus)
fgError("Menu manipulation not allowed while menus in use.");
freeglut_return_if_fail( button >= 0 );
extern GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
unsigned char layer_type );
-extern void fgPlatformCheckMenuDeactivate();
+extern void fgPlatformCheckMenuDeactivate(HWND newFocusWnd);
#ifdef WM_TOUCH
typedef BOOL (WINAPI *pGetTouchInputInfo)(HTOUCHINPUT,UINT,PTOUCHINPUT,int);
lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
/* Check if there are any open menus that need to be closed */
- fgPlatformCheckMenuDeactivate();
+ fgPlatformCheckMenuDeactivate((HWND)wParam);
break;
case WM_MOUSEACTIVATE:
/* Clicks should not activate the menu.
* Especially important when clicking on a menu's submenu item which has no effect.
*/
- printf("WM_MOUSEACTIVATE\n");
+ /*printf("WM_MOUSEACTIVATE\n");*/
if (window->IsMenu)
lRet = MA_NOACTIVATEANDEAT;
else
case WM_NCRBUTTONDOWN:
{
SFG_Menu *menu;
- if (fgStructure.Menus.First && (menu = fgGetActiveMenu()))
+ if (fgState.ActiveMenus && (menu = fgGetActiveMenu()))
/* user clicked non-client area of window while a menu is open. Close menu */
fgDeactivateMenu(menu->ParentWindow);
win = win->Parent;
break;
case DesireNormalState:
- if (win->IsMenu)
- cmdShow = SW_SHOWNA; /* Just show, don't activate if its a menu */
+ if (win->IsMenu && (!fgStructure.GameModeWindow || win->ActiveMenu->ParentWindow != fgStructure.GameModeWindow))
+ cmdShow = SW_SHOWNA; /* Just show, don't activate window if its a menu. Only exception is when the parent is a gamemode window as the menu would pop under it when we do this... */
else
cmdShow = SW_SHOW;
break;
*y = glutGet ( GLUT_SCREEN_HEIGHT );
}
-void fgPlatformCheckMenuDeactivate()
+void fgPlatformCheckMenuDeactivate(HWND newFocusWnd)
{
/* User/system switched application focus.
* If we have an open menu, close it.
*/
SFG_Menu* menu = NULL;
- if ( fgStructure.Menus.First )
+ if ( fgState.ActiveMenus )
menu = fgGetActiveMenu();
if ( menu )
- fgDeactivateMenu(menu->ParentWindow);
+ {
+ if (newFocusWnd != menu->Window->Window.Handle)
+ /* When in GameMode, the menu's parent window will lose focus when the menu is opened.
+ * This is sadly necessary as we need to do an activating ShowWindow() for the menu
+ * to pop up over the gamemode window
+ */
+ fgDeactivateMenu(menu->ParentWindow);
+ }
};