- else if (
- ( wnd->IsMenu && wnd->ActiveMenu && wnd->ActiveMenu->ParentWindow!=menu->ParentWindow) || /* Make sure we don't kill the menu when trying to enter a submenu */
- (!wnd->IsMenu && wnd!=menu->ParentWindow)
- )
- /* User switched to another FreeGLUT window */
- fgDeactivateMenu(menu->ParentWindow);
+ else if (!wnd->IsMenu) /* Make sure we don't kill the menu when trying to enter a submenu */
+ {
+ if (wnd!=menu->ParentWindow)
+ /* User switched to another FreeGLUT window */
+ fgDeactivateMenu(menu->ParentWindow);
+ else
+ {
+ /* Check if focus lost because non-client area of
+ * window was pressed (pressing on client area is
+ * handled in fgCheckActiveMenu)
+ */
+ POINT mouse_pos;
+ RECT clientArea = fghGetClientArea(menu->ParentWindow, GL_FALSE);
+ GetCursorPos(&mouse_pos);
+ if ( !PtInRect( &clientArea, mouse_pos ) )
+ fgDeactivateMenu(menu->ParentWindow);
+ }
+ }