Moving the platform-specific window state fields into their own substructure
authorJohn F. Fay <johnffay@nettally.com>
Sun, 29 Jan 2012 19:17:18 +0000 (19:17 +0000)
committerJohn F. Fay <johnffay@nettally.com>
Sun, 29 Jan 2012 19:17:18 +0000 (19:17 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1030 7f0cb862-5218-0410-a997-914c9d46530a

src/Common/freeglut_internal.h
src/Common/freeglut_main.c
src/Common/freeglut_structure.c
src/Common/freeglut_window.c
src/mswin/freeglut_internal_mswin.h
src/mswin/freeglut_window_mswin.c

index bdb1c0b..ebd9340 100644 (file)
@@ -419,19 +419,24 @@ struct tagSFG_Context
 };\r
 \r
 /* Window's state description. This structure should be kept portable. */\r
+#if TARGET_HOST_POSIX_X11\r
+typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;\r
+struct tagSFG_PlatformWindowState\r
+{\r
+    int             OldWidth;           /* Window width from before a resize */\r
+    int             OldHeight;          /*   "    height  "    "    "   "    */\r
+};\r
+#endif\r
+\r
+\r
 typedef struct tagSFG_WindowState SFG_WindowState;\r
 struct tagSFG_WindowState\r
 {\r
     /* Note that on Windows, sizes always refer to the client area, thus without the window decorations */\r
     int             Width;              /* Window's width in pixels          */\r
     int             Height;             /* The same about the height         */\r
-#if TARGET_HOST_POSIX_X11\r
-    int             OldWidth;           /* Window width from before a resize */\r
-    int             OldHeight;          /*   "    height  "    "    "   "    */\r
-#elif TARGET_HOST_MS_WINDOWS\r
-    RECT            OldRect;            /* window rect - stored before the window is made fullscreen */\r
-    DWORD           OldStyle;           /* window style - stored before the window is made fullscreen */\r
-#endif\r
+\r
+       SFG_PlatformWindowState pWState;    /* Window width/height (X11) or rectangle/style (Windows) from before a resize */\r
 \r
     GLboolean       Redisplay;          /* Do we have to redisplay?          */\r
     GLboolean       Visible;            /* Is the window visible now         */\r
index b3bd7ee..66281ea 100644 (file)
@@ -1001,13 +1001,13 @@ void fgPlatformProcessSingleEvent ( void )
                     height = event.xconfigure.height;\r
                 }\r
 \r
-                if( ( width != window->State.OldWidth ) ||\r
-                    ( height != window->State.OldHeight ) )\r
+                if( ( width != window->State.pWState.OldWidth ) ||\r
+                    ( height != window->State.pWState.OldHeight ) )\r
                 {\r
                     SFG_Window *current_window = fgStructure.CurrentWindow;\r
 \r
-                    window->State.OldWidth = width;\r
-                    window->State.OldHeight = height;\r
+                    window->State.pWState.OldWidth = width;\r
+                    window->State.pWState.OldHeight = height;\r
                     if( FETCH_WCB( *window, Reshape ) )\r
                         INVOKE_WCB( *window, Reshape, ( width, height ) );\r
                     else\r
index 56798f1..59a8b83 100644 (file)
@@ -65,7 +65,7 @@ void fgPlatformCreateWindow ( SFG_Window *window )
 {\r
     window->Window.pContext.FBConfig = NULL;\r
 \r
-    window->State.OldHeight = window->State.OldWidth = -1;\r
+    window->State.pWState.OldHeight = window->State.pWState.OldWidth = -1;\r
 }\r
 #endif\r
 \r
index cde6407..1052c25 100644 (file)
@@ -449,8 +449,8 @@ static int fghResizeFullscrToggle(void)
         /* restore original window size */\r
         SFG_Window *win = fgStructure.CurrentWindow;\r
         fgStructure.CurrentWindow->State.NeedToResize = GL_TRUE;\r
-        fgStructure.CurrentWindow->State.Width  = win->State.OldWidth;\r
-        fgStructure.CurrentWindow->State.Height = win->State.OldHeight;\r
+        fgStructure.CurrentWindow->State.Width  = win->State.pWState.OldWidth;\r
+        fgStructure.CurrentWindow->State.Height = win->State.pWState.OldHeight;\r
 \r
     } else {\r
         /* resize the window to cover the entire screen */\r
index 78ad1fe..8712ad9 100644 (file)
@@ -85,6 +85,16 @@ struct tagSFG_PlatformContext
 };\r
 \r
 \r
+/* Window's state description. This structure should be kept portable. */\r
+typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;\r
+struct tagSFG_PlatformWindowState\r
+{\r
+    RECT            OldRect;            /* window rect - stored before the window is made fullscreen */\r
+    DWORD           OldStyle;           /* window style - stored before the window is made fullscreen */\r
+};\r
+\r
+\r
+\r
 /* Joystick-Specific Definitions */\r
 #if !defined(_WIN32_WCE)\r
 #    define _JS_MAX_AXES  8\r
index 5a33ec5..cd0400a 100644 (file)
@@ -978,10 +978,10 @@ void fgPlatformGlutFullScreen( SFG_Window *win )
 \r
         \r
         /* store current window rect */\r
-        GetWindowRect( win->Window.Handle, &win->State.OldRect );\r
+        GetWindowRect( win->Window.Handle, &win->State.pWState.OldRect );\r
 \r
         /* store current window style */\r
-        win->State.OldStyle = s = GetWindowLong(win->Window.Handle, GWL_STYLE);\r
+        win->State.pWState.OldStyle = s = GetWindowLong(win->Window.Handle, GWL_STYLE);\r
 \r
         /* remove decorations from style and add popup style*/\r
         s &= ~WS_OVERLAPPEDWINDOW;\r
@@ -992,7 +992,7 @@ void fgPlatformGlutFullScreen( SFG_Window *win )
         /* For fullscreen mode, find the monitor that is covered the most\r
          * by the window and get its rect as the resize target.\r
             */\r
-        hMonitor= MonitorFromRect(&win->State.OldRect, MONITOR_DEFAULTTONEAREST);\r
+        hMonitor= MonitorFromRect(&win->State.pWState.OldRect, MONITOR_DEFAULTTONEAREST);\r
         mi.cbSize = sizeof(mi);\r
         GetMonitorInfo(hMonitor, &mi);\r
         rect = mi.rcMonitor;\r
@@ -1048,16 +1048,16 @@ void fgPlatformGlutLeaveFullScreen( SFG_Window *win )
     }\r
 \r
     /* restore style of window before making it fullscreen */\r
-    SetWindowLong(win->Window.Handle, GWL_STYLE, win->State.OldStyle);\r
+    SetWindowLong(win->Window.Handle, GWL_STYLE, win->State.pWState.OldStyle);\r
     SetWindowPos(win->Window.Handle, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);\r
 \r
     /* Then resize */\r
     SetWindowPos(win->Window.Handle,\r
         HWND_TOP,\r
-        win->State.OldRect.left,\r
-        win->State.OldRect.top,\r
-        win->State.OldRect.right  - win->State.OldRect.left,\r
-        win->State.OldRect.bottom - win->State.OldRect.top,\r
+        win->State.pWState.OldRect.left,\r
+        win->State.pWState.OldRect.top,\r
+        win->State.pWState.OldRect.right  - win->State.pWState.OldRect.left,\r
+        win->State.pWState.OldRect.bottom - win->State.pWState.OldRect.top,\r
         SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |\r
         SWP_NOZORDER\r
         );\r