Moving the platform-specific window state fields into their own substructure

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1030 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
fayjf 2012-01-29 19:17:18 +00:00
parent dbc94b3d56
commit 89d7b12018
6 changed files with 37 additions and 22 deletions

View File

@ -419,19 +419,24 @@ struct tagSFG_Context
}; };
/* Window's state description. This structure should be kept portable. */ /* 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; typedef struct tagSFG_WindowState SFG_WindowState;
struct tagSFG_WindowState struct tagSFG_WindowState
{ {
/* Note that on Windows, sizes always refer to the client area, thus without the window decorations */ /* Note that on Windows, sizes always refer to the client area, thus without the window decorations */
int Width; /* Window's width in pixels */ int Width; /* Window's width in pixels */
int Height; /* The same about the height */ int Height; /* The same about the height */
#if TARGET_HOST_POSIX_X11
int OldWidth; /* Window width from before a resize */ SFG_PlatformWindowState pWState; /* Window width/height (X11) or rectangle/style (Windows) 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
GLboolean Redisplay; /* Do we have to redisplay? */ GLboolean Redisplay; /* Do we have to redisplay? */
GLboolean Visible; /* Is the window visible now */ GLboolean Visible; /* Is the window visible now */

View File

@ -1001,13 +1001,13 @@ void fgPlatformProcessSingleEvent ( void )
height = event.xconfigure.height; height = event.xconfigure.height;
} }
if( ( width != window->State.OldWidth ) || if( ( width != window->State.pWState.OldWidth ) ||
( height != window->State.OldHeight ) ) ( height != window->State.pWState.OldHeight ) )
{ {
SFG_Window *current_window = fgStructure.CurrentWindow; SFG_Window *current_window = fgStructure.CurrentWindow;
window->State.OldWidth = width; window->State.pWState.OldWidth = width;
window->State.OldHeight = height; window->State.pWState.OldHeight = height;
if( FETCH_WCB( *window, Reshape ) ) if( FETCH_WCB( *window, Reshape ) )
INVOKE_WCB( *window, Reshape, ( width, height ) ); INVOKE_WCB( *window, Reshape, ( width, height ) );
else else

View File

@ -65,7 +65,7 @@ void fgPlatformCreateWindow ( SFG_Window *window )
{ {
window->Window.pContext.FBConfig = NULL; window->Window.pContext.FBConfig = NULL;
window->State.OldHeight = window->State.OldWidth = -1; window->State.pWState.OldHeight = window->State.pWState.OldWidth = -1;
} }
#endif #endif

View File

@ -449,8 +449,8 @@ static int fghResizeFullscrToggle(void)
/* restore original window size */ /* restore original window size */
SFG_Window *win = fgStructure.CurrentWindow; SFG_Window *win = fgStructure.CurrentWindow;
fgStructure.CurrentWindow->State.NeedToResize = GL_TRUE; fgStructure.CurrentWindow->State.NeedToResize = GL_TRUE;
fgStructure.CurrentWindow->State.Width = win->State.OldWidth; fgStructure.CurrentWindow->State.Width = win->State.pWState.OldWidth;
fgStructure.CurrentWindow->State.Height = win->State.OldHeight; fgStructure.CurrentWindow->State.Height = win->State.pWState.OldHeight;
} else { } else {
/* resize the window to cover the entire screen */ /* resize the window to cover the entire screen */

View File

@ -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 */ /* Joystick-Specific Definitions */
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
# define _JS_MAX_AXES 8 # define _JS_MAX_AXES 8

View File

@ -978,10 +978,10 @@ void fgPlatformGlutFullScreen( SFG_Window *win )
/* store current window rect */ /* store current window rect */
GetWindowRect( win->Window.Handle, &win->State.OldRect ); GetWindowRect( win->Window.Handle, &win->State.pWState.OldRect );
/* store current window style */ /* 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*/ /* remove decorations from style and add popup style*/
s &= ~WS_OVERLAPPEDWINDOW; s &= ~WS_OVERLAPPEDWINDOW;
@ -992,7 +992,7 @@ void fgPlatformGlutFullScreen( SFG_Window *win )
/* For fullscreen mode, find the monitor that is covered the most /* For fullscreen mode, find the monitor that is covered the most
* by the window and get its rect as the resize target. * 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); mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi); GetMonitorInfo(hMonitor, &mi);
rect = mi.rcMonitor; rect = mi.rcMonitor;
@ -1048,16 +1048,16 @@ void fgPlatformGlutLeaveFullScreen( SFG_Window *win )
} }
/* restore style of window before making it fullscreen */ /* 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); SetWindowPos(win->Window.Handle, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
/* Then resize */ /* Then resize */
SetWindowPos(win->Window.Handle, SetWindowPos(win->Window.Handle,
HWND_TOP, HWND_TOP,
win->State.OldRect.left, win->State.pWState.OldRect.left,
win->State.OldRect.top, win->State.pWState.OldRect.top,
win->State.OldRect.right - win->State.OldRect.left, win->State.pWState.OldRect.right - win->State.pWState.OldRect.left,
win->State.OldRect.bottom - win->State.OldRect.top, win->State.pWState.OldRect.bottom - win->State.pWState.OldRect.top,
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
SWP_NOZORDER SWP_NOZORDER
); );