Ensure "maximixed" is taken into account when updating window visibility on WM_SIZE
[freeglut] / src / mswin / fg_main_mswin.c
index f528dd1..1958755 100644 (file)
@@ -874,7 +874,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
         /* Update visibility state of the window */
         if (wParam==SIZE_MINIMIZED)
             fghPlatformOnWindowStatusNotify(window,GL_FALSE,GL_FALSE);
-        else if (wParam==SIZE_RESTORED && !window->State.Visible)
+        else if ((wParam==SIZE_RESTORED || wParam == SIZE_MAXIMIZED) && !window->State.Visible)
             fghPlatformOnWindowStatusNotify(window,GL_TRUE,GL_FALSE);
 
         /* Check window visible, we don't want do anything when we get a WM_SIZE because the user or glutIconifyWindow minimized the window */
@@ -1543,6 +1543,16 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
                break;
        }
 #endif
+
+#ifdef WM_INPUT
+       case WM_INPUT:
+        /* Added by Jinrong Xie <stonexjr at gmail.com> for SpaceNavigator support on Windows. Dec 2014 */
+               if (fgHasSpaceball())
+               {
+                       fgSpaceballHandleWinEvent(hWnd, wParam, lParam);
+               }
+               break;
+#endif
     default:
         /* Handle unhandled messages */
         lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
@@ -1640,8 +1650,7 @@ void fgPlatformPosResZordWork(SFG_Window* window, unsigned int workMask)
             /* For fullscreen mode, find the monitor that is covered the most
                 * by the window and get its rect as the resize target.
                    */
-            GetWindowRect(window->Window.Handle, &rect);
-            hMonitor= MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST);
+            hMonitor= MonitorFromWindow(window->Window.Handle, MONITOR_DEFAULTTONEAREST);
             mi.cbSize = sizeof(mi);
             GetMonitorInfo(hMonitor, &mi);
             rect = mi.rcMonitor;