From dba5bb070e01654caf13b0414e9ac5f6bd5fb7a1 Mon Sep 17 00:00:00 2001 From: dcnieho Date: Mon, 23 Jul 2012 07:04:06 +0000 Subject: [PATCH] now also closing menus when non-client area is pressed (thanks for suggestions Ioannis!) git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1362 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/src/mswin/fg_main_mswin.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/freeglut/freeglut/src/mswin/fg_main_mswin.c b/freeglut/freeglut/src/mswin/fg_main_mswin.c index 28e1b64..3afc655 100644 --- a/freeglut/freeglut/src/mswin/fg_main_mswin.c +++ b/freeglut/freeglut/src/mswin/fg_main_mswin.c @@ -532,6 +532,18 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, else if (!wnd->IsMenu && wnd!=menu->ParentWindow) /* Make sure we don't kill the menu when trying to enter a submenu */ /* 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); + } } } break;