X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmswin%2Ffg_main_mswin.c;h=be8248ecb88fda601a1d03aa4f6ea12c27099add;hb=450b0d2bd03f4d7721fa2fe5f54f38d787accb06;hp=b09e8bc015c0c5e95ed8e1817bd4713f5fc4a85d;hpb=d9b0989056a1c2267b68f01317d4641c70e48719;p=freeglut diff --git a/src/mswin/fg_main_mswin.c b/src/mswin/fg_main_mswin.c index b09e8bc..be8248e 100644 --- a/src/mswin/fg_main_mswin.c +++ b/src/mswin/fg_main_mswin.c @@ -240,7 +240,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, uMsg, wParam, lParam ); */ /* Some events only sent to main window. Check if the current window that - * the mouse is over is a child window. Below whn handling some messages, + * the mouse is over is a child window. Below when handling some messages, * we make sure that we process callbacks on the child window instead. * This mirrors how GLUT does things. */ @@ -518,9 +518,11 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, case WM_KILLFOCUS: { SFG_Menu* menu = NULL; + SFG_Window* saved_window = fgStructure.CurrentWindow; /* printf("WM_KILLFOCUS: %p\n", window ); */ lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); INVOKE_WCB( *window, Entry, ( GLUT_LEFT ) ); + fgSetWindow(saved_window); /* If we have an open menu, see if the open menu should be closed * when focus was lost because user either switched @@ -541,20 +543,23 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, if (!hwnd || !wnd) /* User switched to another application*/ fgDeactivateMenu(menu->ParentWindow); - 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 + else if (!wnd->IsMenu) /* Make sure we don't kill the menu when trying to enter a submenu */ { - /* 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 ) ) + 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); + } } } }