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:
parent
de8936fe30
commit
5707f479d4
@ -428,6 +428,8 @@ int FGAPIENTRY glutEnterGameMode( void )
|
|||||||
fgState.GameModeSize.X, fgState.GameModeSize.Y, GL_TRUE, GL_FALSE
|
fgState.GameModeSize.X, fgState.GameModeSize.Y, GL_TRUE, GL_FALSE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
fgStructure.GameMode->State.IsGameMode = GL_TRUE;
|
||||||
|
|
||||||
#if TARGET_HOST_UNIX_X11
|
#if TARGET_HOST_UNIX_X11
|
||||||
|
|
||||||
/* Move the window up to the topleft corner */
|
/* Move the window up to the topleft corner */
|
||||||
@ -534,6 +536,8 @@ void FGAPIENTRY glutLeaveGameMode( void )
|
|||||||
{
|
{
|
||||||
freeglut_return_if_fail( fgStructure.GameMode );
|
freeglut_return_if_fail( fgStructure.GameMode );
|
||||||
|
|
||||||
|
fgStructure.GameMode->State.IsGameMode = GL_FALSE;
|
||||||
|
|
||||||
fgAddToWindowDestroyList( fgStructure.GameMode );
|
fgAddToWindowDestroyList( fgStructure.GameMode );
|
||||||
|
|
||||||
#if TARGET_HOST_UNIX_X11
|
#if TARGET_HOST_UNIX_X11
|
||||||
|
@ -87,42 +87,49 @@ static void fghReshapeWindowByHandle ( SFG_WindowHandleType handle,
|
|||||||
#elif TARGET_HOST_WIN32
|
#elif TARGET_HOST_WIN32
|
||||||
|
|
||||||
{
|
{
|
||||||
RECT winRect;
|
RECT rect;
|
||||||
int x, y;
|
|
||||||
|
|
||||||
GetWindowRect( window->Window.Handle, &winRect );
|
/*
|
||||||
x = winRect.left;
|
* For windowed mode, get the current position of the
|
||||||
y = winRect.top;
|
* 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 )
|
if ( window->Parent == NULL )
|
||||||
{
|
{
|
||||||
/*
|
if ( ! window->IsMenu && !window->State.IsGameMode )
|
||||||
* Adjust the size of the window to allow for the size of the
|
|
||||||
* frame, if we are not a menu
|
|
||||||
*/
|
|
||||||
if ( ! window->IsMenu )
|
|
||||||
{
|
{
|
||||||
width += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
|
rect.right += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
|
||||||
height += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
|
rect.bottom += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
|
||||||
GetSystemMetrics( SM_CYCAPTION );
|
GetSystemMetrics( SM_CYCAPTION );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GetWindowRect( window->Parent->Window.Handle,
|
GetWindowRect( window->Parent->Window.Handle, &rect );
|
||||||
&winRect );
|
AdjustWindowRect ( &rect, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS |
|
||||||
x -= winRect.left + GetSystemMetrics( SM_CXSIZEFRAME );
|
WS_CLIPCHILDREN, FALSE );
|
||||||
y -= winRect.top + GetSystemMetrics( SM_CYSIZEFRAME ) +
|
|
||||||
GetSystemMetrics( SM_CYCAPTION );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveWindow(
|
/*
|
||||||
window->Window.Handle,
|
* SWP_NOACTIVATE Do not activate the window
|
||||||
x,
|
* SWP_NOOWNERZORDER Do not change position in z-order
|
||||||
y,
|
* SWP_NOSENDCHANGING Supress WM_WINDOWPOSCHANGING message
|
||||||
width,
|
* SWP_NOZORDER Retains the current Z order (ignore 2nd param)
|
||||||
height,
|
*/
|
||||||
TRUE
|
|
||||||
|
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
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,13 +943,39 @@ void FGAPIENTRY glutFullScreen( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif TARGET_HOST_WIN32
|
#elif TARGET_HOST_WIN32
|
||||||
MoveWindow(
|
{
|
||||||
fgStructure.Window->Window.Handle,
|
RECT rect;
|
||||||
0, 0,
|
|
||||||
fgDisplay.ScreenWidth,
|
/* For fullscreen mode, force the top-left corner to 0,0
|
||||||
fgDisplay.ScreenHeight,
|
* and adjust the window rectangle so that the client area
|
||||||
TRUE
|
* 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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user