Nigel Stewart's Win32 window-sizing fix for game mode

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@389 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
puggles 2003-12-11 18:53:06 +00:00
parent de8936fe30
commit 5707f479d4
3 changed files with 69 additions and 32 deletions

View File

@ -428,6 +428,8 @@ int FGAPIENTRY glutEnterGameMode( void )
fgState.GameModeSize.X, fgState.GameModeSize.Y, GL_TRUE, GL_FALSE
);
fgStructure.GameMode->State.IsGameMode = GL_TRUE;
#if TARGET_HOST_UNIX_X11
/* Move the window up to the topleft corner */
@ -534,6 +536,8 @@ void FGAPIENTRY glutLeaveGameMode( void )
{
freeglut_return_if_fail( fgStructure.GameMode );
fgStructure.GameMode->State.IsGameMode = GL_FALSE;
fgAddToWindowDestroyList( fgStructure.GameMode );
#if TARGET_HOST_UNIX_X11

View File

@ -87,42 +87,49 @@ static void fghReshapeWindowByHandle ( SFG_WindowHandleType handle,
#elif TARGET_HOST_WIN32
{
RECT winRect;
int x, y;
RECT rect;
GetWindowRect( window->Window.Handle, &winRect );
x = winRect.left;
y = winRect.top;
/*
* For windowed mode, get the current position of the
* window and resize taking the size of the frame
* decorations into account.
*/
GetWindowRect( window->Window.Handle, &rect );
rect.right = rect.left + width;
rect.bottom = rect.top + height;
if ( window->Parent == NULL )
{
/*
* Adjust the size of the window to allow for the size of the
* frame, if we are not a menu
*/
if ( ! window->IsMenu )
if ( ! window->IsMenu && !window->State.IsGameMode )
{
width += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
height += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
GetSystemMetrics( SM_CYCAPTION );
rect.right += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
rect.bottom += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
GetSystemMetrics( SM_CYCAPTION );
}
}
else
{
GetWindowRect( window->Parent->Window.Handle,
&winRect );
x -= winRect.left + GetSystemMetrics( SM_CXSIZEFRAME );
y -= winRect.top + GetSystemMetrics( SM_CYSIZEFRAME ) +
GetSystemMetrics( SM_CYCAPTION );
GetWindowRect( window->Parent->Window.Handle, &rect );
AdjustWindowRect ( &rect, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN, FALSE );
}
MoveWindow(
window->Window.Handle,
x,
y,
width,
height,
TRUE
/*
* SWP_NOACTIVATE Do not activate the window
* SWP_NOOWNERZORDER Do not change position in z-order
* SWP_NOSENDCHANGING Supress WM_WINDOWPOSCHANGING message
* SWP_NOZORDER Retains the current Z order (ignore 2nd param)
*/
SetWindowPos( window->Window.Handle,
HWND_TOP,
rect.left,
rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
SWP_NOZORDER
);
}

View File

@ -943,13 +943,39 @@ void FGAPIENTRY glutFullScreen( void )
}
}
#elif TARGET_HOST_WIN32
MoveWindow(
fgStructure.Window->Window.Handle,
0, 0,
fgDisplay.ScreenWidth,
fgDisplay.ScreenHeight,
TRUE
);
{
RECT rect;
/* For fullscreen mode, force the top-left corner to 0,0
* and adjust the window rectangle so that the client area
* covers the whole screen.
*/
rect.left = 0;
rect.top = 0;
rect.right = fgDisplay.ScreenWidth;
rect.bottom = fgDisplay.ScreenHeight;
AdjustWindowRect ( &rect, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN, FALSE );
/*
* SWP_NOACTIVATE Do not activate the window
* SWP_NOOWNERZORDER Do not change position in z-order
* SWP_NOSENDCHANGING Supress WM_WINDOWPOSCHANGING message
* SWP_NOZORDER Retains the current Z order (ignore 2nd param)
*/
SetWindowPos( fgStructure.Window->Window.Handle,
HWND_TOP,
rect.left,
rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
SWP_NOZORDER
);
}
#endif
}