Should only do check if mouse is outside client area when not opening a
authorDiederick Niehorster <dcnieho@gmail.com>
Mon, 23 Jul 2012 09:50:14 +0000 (09:50 +0000)
committerDiederick Niehorster <dcnieho@gmail.com>
Mon, 23 Jul 2012 09:50:14 +0000 (09:50 +0000)
submenu as well...

git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1364 7f0cb862-5218-0410-a997-914c9d46530a

src/mswin/fg_main_mswin.c

index b09e8bc..663ff3b 100644 (file)
@@ -541,20 +541,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);
+                    }
                 }
             }
         }