From: John F. Fay Date: Sun, 29 Jan 2012 19:17:18 +0000 (+0000) Subject: Moving the platform-specific window state fields into their own substructure X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;ds=sidebyside;h=0cd6817079c9f545bbff65d6ac86d9fac6b92db9;p=freeglut Moving the platform-specific window state fields into their own substructure git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1030 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/src/Common/freeglut_internal.h b/src/Common/freeglut_internal.h index bdb1c0b..ebd9340 100644 --- a/src/Common/freeglut_internal.h +++ b/src/Common/freeglut_internal.h @@ -419,19 +419,24 @@ struct tagSFG_Context }; /* Window's state description. This structure should be kept portable. */ +#if TARGET_HOST_POSIX_X11 +typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState; +struct tagSFG_PlatformWindowState +{ + int OldWidth; /* Window width from before a resize */ + int OldHeight; /* " height " " " " */ +}; +#endif + + typedef struct tagSFG_WindowState SFG_WindowState; struct tagSFG_WindowState { /* Note that on Windows, sizes always refer to the client area, thus without the window decorations */ int Width; /* Window's width in pixels */ int Height; /* The same about the height */ -#if TARGET_HOST_POSIX_X11 - int OldWidth; /* Window width from before a resize */ - int OldHeight; /* " height " " " " */ -#elif TARGET_HOST_MS_WINDOWS - RECT OldRect; /* window rect - stored before the window is made fullscreen */ - DWORD OldStyle; /* window style - stored before the window is made fullscreen */ -#endif + + SFG_PlatformWindowState pWState; /* Window width/height (X11) or rectangle/style (Windows) from before a resize */ GLboolean Redisplay; /* Do we have to redisplay? */ GLboolean Visible; /* Is the window visible now */ diff --git a/src/Common/freeglut_main.c b/src/Common/freeglut_main.c index b3bd7ee..66281ea 100644 --- a/src/Common/freeglut_main.c +++ b/src/Common/freeglut_main.c @@ -1001,13 +1001,13 @@ void fgPlatformProcessSingleEvent ( void ) height = event.xconfigure.height; } - if( ( width != window->State.OldWidth ) || - ( height != window->State.OldHeight ) ) + if( ( width != window->State.pWState.OldWidth ) || + ( height != window->State.pWState.OldHeight ) ) { SFG_Window *current_window = fgStructure.CurrentWindow; - window->State.OldWidth = width; - window->State.OldHeight = height; + window->State.pWState.OldWidth = width; + window->State.pWState.OldHeight = height; if( FETCH_WCB( *window, Reshape ) ) INVOKE_WCB( *window, Reshape, ( width, height ) ); else diff --git a/src/Common/freeglut_structure.c b/src/Common/freeglut_structure.c index 56798f1..59a8b83 100644 --- a/src/Common/freeglut_structure.c +++ b/src/Common/freeglut_structure.c @@ -65,7 +65,7 @@ void fgPlatformCreateWindow ( SFG_Window *window ) { window->Window.pContext.FBConfig = NULL; - window->State.OldHeight = window->State.OldWidth = -1; + window->State.pWState.OldHeight = window->State.pWState.OldWidth = -1; } #endif diff --git a/src/Common/freeglut_window.c b/src/Common/freeglut_window.c index cde6407..1052c25 100644 --- a/src/Common/freeglut_window.c +++ b/src/Common/freeglut_window.c @@ -449,8 +449,8 @@ static int fghResizeFullscrToggle(void) /* restore original window size */ SFG_Window *win = fgStructure.CurrentWindow; fgStructure.CurrentWindow->State.NeedToResize = GL_TRUE; - fgStructure.CurrentWindow->State.Width = win->State.OldWidth; - fgStructure.CurrentWindow->State.Height = win->State.OldHeight; + fgStructure.CurrentWindow->State.Width = win->State.pWState.OldWidth; + fgStructure.CurrentWindow->State.Height = win->State.pWState.OldHeight; } else { /* resize the window to cover the entire screen */ diff --git a/src/mswin/freeglut_internal_mswin.h b/src/mswin/freeglut_internal_mswin.h index 78ad1fe..8712ad9 100644 --- a/src/mswin/freeglut_internal_mswin.h +++ b/src/mswin/freeglut_internal_mswin.h @@ -85,6 +85,16 @@ struct tagSFG_PlatformContext }; +/* Window's state description. This structure should be kept portable. */ +typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState; +struct tagSFG_PlatformWindowState +{ + RECT OldRect; /* window rect - stored before the window is made fullscreen */ + DWORD OldStyle; /* window style - stored before the window is made fullscreen */ +}; + + + /* Joystick-Specific Definitions */ #if !defined(_WIN32_WCE) # define _JS_MAX_AXES 8 diff --git a/src/mswin/freeglut_window_mswin.c b/src/mswin/freeglut_window_mswin.c index 5a33ec5..cd0400a 100644 --- a/src/mswin/freeglut_window_mswin.c +++ b/src/mswin/freeglut_window_mswin.c @@ -978,10 +978,10 @@ void fgPlatformGlutFullScreen( SFG_Window *win ) /* store current window rect */ - GetWindowRect( win->Window.Handle, &win->State.OldRect ); + GetWindowRect( win->Window.Handle, &win->State.pWState.OldRect ); /* store current window style */ - win->State.OldStyle = s = GetWindowLong(win->Window.Handle, GWL_STYLE); + win->State.pWState.OldStyle = s = GetWindowLong(win->Window.Handle, GWL_STYLE); /* remove decorations from style and add popup style*/ s &= ~WS_OVERLAPPEDWINDOW; @@ -992,7 +992,7 @@ void fgPlatformGlutFullScreen( SFG_Window *win ) /* For fullscreen mode, find the monitor that is covered the most * by the window and get its rect as the resize target. */ - hMonitor= MonitorFromRect(&win->State.OldRect, MONITOR_DEFAULTTONEAREST); + hMonitor= MonitorFromRect(&win->State.pWState.OldRect, MONITOR_DEFAULTTONEAREST); mi.cbSize = sizeof(mi); GetMonitorInfo(hMonitor, &mi); rect = mi.rcMonitor; @@ -1048,16 +1048,16 @@ void fgPlatformGlutLeaveFullScreen( SFG_Window *win ) } /* restore style of window before making it fullscreen */ - SetWindowLong(win->Window.Handle, GWL_STYLE, win->State.OldStyle); + SetWindowLong(win->Window.Handle, GWL_STYLE, win->State.pWState.OldStyle); SetWindowPos(win->Window.Handle, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); /* Then resize */ SetWindowPos(win->Window.Handle, HWND_TOP, - win->State.OldRect.left, - win->State.OldRect.top, - win->State.OldRect.right - win->State.OldRect.left, - win->State.OldRect.bottom - win->State.OldRect.top, + win->State.pWState.OldRect.left, + win->State.pWState.OldRect.top, + win->State.pWState.OldRect.right - win->State.pWState.OldRect.left, + win->State.pWState.OldRect.bottom - win->State.pWState.OldRect.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOZORDER );