Splitting the rest of the Windows-specific "freeglut_window.c" functions into their own file
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1003 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
4c2d8597d3
commit
cec64541a5
@ -128,6 +128,18 @@ extern void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
||||
GLboolean sizeUse, int w, int h,
|
||||
GLboolean gameMode, GLboolean isSubWindow );
|
||||
extern void fgPlatformCloseWindow( SFG_Window* window );
|
||||
extern void fgPlatformGlutShowWindow( void );
|
||||
extern void fgPlatformGlutHideWindow( void );
|
||||
extern void fgPlatformGlutIconifyWindow( void );
|
||||
extern void fgPlatformGlutSetWindowTitle( const char* title );
|
||||
extern void fgPlatformGlutSetIconTitle( const char* title );
|
||||
extern void fgPlatformGlutPositionWindow( int x, int y );
|
||||
extern void fgPlatformGlutPushWindow( void );
|
||||
extern void fgPlatformGlutPopWindow( void );
|
||||
extern void fgPlatformGlutFullScreen( SFG_Window *win );
|
||||
extern void fgPlatformGlutLeaveFullScreen( SFG_Window *win );
|
||||
extern void fgPlatformGlutFullScreenToggle( SFG_Window *win );
|
||||
|
||||
|
||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||
|
||||
@ -751,6 +763,154 @@ void fgPlatformCloseWindow( SFG_Window* window )
|
||||
/* XFlush( fgDisplay.Display ); */ /* XXX Shouldn't need this */
|
||||
}
|
||||
|
||||
|
||||
static Bool fghWindowIsVisible( Display *display, XEvent *event, XPointer arg)
|
||||
{
|
||||
Window window = (Window)arg;
|
||||
return (event->type == MapNotify) && (event->xmap.window == window);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This function makes the current window visible
|
||||
*/
|
||||
void fgPlatformGlutShowWindow( void )
|
||||
{
|
||||
XMapWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle );
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
}
|
||||
|
||||
/*
|
||||
* This function hides the current window
|
||||
*/
|
||||
void fgPlatformGlutHideWindow( void )
|
||||
{
|
||||
if( fgStructure.CurrentWindow->Parent == NULL )
|
||||
XWithdrawWindow( fgDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
fgDisplay.Screen );
|
||||
else
|
||||
XUnmapWindow( fgDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle );
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
}
|
||||
|
||||
/*
|
||||
* Iconify the current window (top-level windows only)
|
||||
*/
|
||||
void fgPlatformGlutIconifyWindow( void )
|
||||
{
|
||||
XIconifyWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle,
|
||||
fgDisplay.Screen );
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the current window's title
|
||||
*/
|
||||
void fgPlatformGlutSetWindowTitle( const char* title )
|
||||
{
|
||||
XTextProperty text;
|
||||
|
||||
text.value = (unsigned char *) title;
|
||||
text.encoding = XA_STRING;
|
||||
text.format = 8;
|
||||
text.nitems = strlen( title );
|
||||
|
||||
XSetWMName(
|
||||
fgDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
&text
|
||||
);
|
||||
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the current window's iconified title
|
||||
*/
|
||||
void fgPlatformGlutSetIconTitle( const char* title )
|
||||
{
|
||||
XTextProperty text;
|
||||
|
||||
text.value = (unsigned char *) title;
|
||||
text.encoding = XA_STRING;
|
||||
text.format = 8;
|
||||
text.nitems = strlen( title );
|
||||
|
||||
XSetWMIconName(
|
||||
fgDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
&text
|
||||
);
|
||||
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
}
|
||||
|
||||
/*
|
||||
* Change the current window's position
|
||||
*/
|
||||
void fgPlatformGlutPositionWindow( int x, int y )
|
||||
{
|
||||
XMoveWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle,
|
||||
x, y );
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
}
|
||||
|
||||
/*
|
||||
* Lowers the current window (by Z order change)
|
||||
*/
|
||||
void fgPlatformGlutPushWindow( void )
|
||||
{
|
||||
XLowerWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle );
|
||||
}
|
||||
|
||||
/*
|
||||
* Raises the current window (by Z order change)
|
||||
*/
|
||||
void fgPlatformGlutPopWindow( void )
|
||||
{
|
||||
XRaiseWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle );
|
||||
}
|
||||
|
||||
/*
|
||||
* Resize the current window so that it fits the whole screen
|
||||
*/
|
||||
void fgPlatformGlutFullScreen( SFG_Window *win )
|
||||
{
|
||||
if(!glutGet(GLUT_FULL_SCREEN)) {
|
||||
if(fghToggleFullscreen() != -1) {
|
||||
win->State.IsFullscreen = GL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If we are fullscreen, resize the current window back to its original size
|
||||
*/
|
||||
void fgPlatformGlutLeaveFullScreen( SFG_Window *win )
|
||||
{
|
||||
if(glutGet(GLUT_FULL_SCREEN)) {
|
||||
if(fghToggleFullscreen() != -1) {
|
||||
win->State.IsFullscreen = GL_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Toggle the window's full screen state.
|
||||
*/
|
||||
void fgPlatformGlutFullScreenToggle( SFG_Window *win )
|
||||
{
|
||||
if(fghToggleFullscreen() != -1) {
|
||||
win->State.IsFullscreen = !win->State.IsFullscreen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* TARGET_HOST_POSIX_X11 */
|
||||
|
||||
|
||||
@ -766,13 +926,6 @@ void fgSetWindow ( SFG_Window *window )
|
||||
}
|
||||
|
||||
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
static Bool fghWindowIsVisible( Display *display, XEvent *event, XPointer arg)
|
||||
{
|
||||
Window window = (Window)arg;
|
||||
return (event->type == MapNotify) && (event->xmap.window == window);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@ -955,16 +1108,7 @@ void FGAPIENTRY glutShowWindow( void )
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutShowWindow" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutShowWindow" );
|
||||
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
|
||||
XMapWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle );
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
|
||||
#elif TARGET_HOST_MS_WINDOWS
|
||||
|
||||
ShowWindow( fgStructure.CurrentWindow->Window.Handle, SW_SHOW );
|
||||
|
||||
#endif
|
||||
fgPlatformGlutShowWindow ();
|
||||
|
||||
fgStructure.CurrentWindow->State.Redisplay = GL_TRUE;
|
||||
}
|
||||
@ -977,22 +1121,7 @@ void FGAPIENTRY glutHideWindow( void )
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutHideWindow" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutHideWindow" );
|
||||
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
|
||||
if( fgStructure.CurrentWindow->Parent == NULL )
|
||||
XWithdrawWindow( fgDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
fgDisplay.Screen );
|
||||
else
|
||||
XUnmapWindow( fgDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle );
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
|
||||
#elif TARGET_HOST_MS_WINDOWS
|
||||
|
||||
ShowWindow( fgStructure.CurrentWindow->Window.Handle, SW_HIDE );
|
||||
|
||||
#endif
|
||||
fgPlatformGlutHideWindow ();
|
||||
|
||||
fgStructure.CurrentWindow->State.Redisplay = GL_FALSE;
|
||||
}
|
||||
@ -1006,17 +1135,8 @@ void FGAPIENTRY glutIconifyWindow( void )
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutIconifyWindow" );
|
||||
|
||||
fgStructure.CurrentWindow->State.Visible = GL_FALSE;
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
|
||||
XIconifyWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle,
|
||||
fgDisplay.Screen );
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
|
||||
#elif TARGET_HOST_MS_WINDOWS
|
||||
|
||||
ShowWindow( fgStructure.CurrentWindow->Window.Handle, SW_MINIMIZE );
|
||||
|
||||
#endif
|
||||
fgPlatformGlutIconifyWindow ();
|
||||
|
||||
fgStructure.CurrentWindow->State.Redisplay = GL_FALSE;
|
||||
}
|
||||
@ -1030,35 +1150,7 @@ void FGAPIENTRY glutSetWindowTitle( const char* title )
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetWindowTitle" );
|
||||
if( ! fgStructure.CurrentWindow->Parent )
|
||||
{
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
|
||||
XTextProperty text;
|
||||
|
||||
text.value = (unsigned char *) title;
|
||||
text.encoding = XA_STRING;
|
||||
text.format = 8;
|
||||
text.nitems = strlen( title );
|
||||
|
||||
XSetWMName(
|
||||
fgDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
&text
|
||||
);
|
||||
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
|
||||
#elif TARGET_HOST_MS_WINDOWS
|
||||
# ifdef _WIN32_WCE
|
||||
{
|
||||
wchar_t* wstr = fghWstrFromStr(title);
|
||||
SetWindowText( fgStructure.CurrentWindow->Window.Handle, wstr );
|
||||
free(wstr);
|
||||
}
|
||||
# else
|
||||
SetWindowText( fgStructure.CurrentWindow->Window.Handle, title );
|
||||
# endif
|
||||
|
||||
#endif
|
||||
fgPlatformGlutSetWindowTitle ( title );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1072,35 +1164,7 @@ void FGAPIENTRY glutSetIconTitle( const char* title )
|
||||
|
||||
if( ! fgStructure.CurrentWindow->Parent )
|
||||
{
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
|
||||
XTextProperty text;
|
||||
|
||||
text.value = (unsigned char *) title;
|
||||
text.encoding = XA_STRING;
|
||||
text.format = 8;
|
||||
text.nitems = strlen( title );
|
||||
|
||||
XSetWMIconName(
|
||||
fgDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
&text
|
||||
);
|
||||
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
|
||||
#elif TARGET_HOST_MS_WINDOWS
|
||||
# ifdef _WIN32_WCE
|
||||
{
|
||||
wchar_t* wstr = fghWstrFromStr(title);
|
||||
SetWindowText( fgStructure.CurrentWindow->Window.Handle, wstr );
|
||||
free(wstr);
|
||||
}
|
||||
# else
|
||||
SetWindowText( fgStructure.CurrentWindow->Window.Handle, title );
|
||||
# endif
|
||||
|
||||
#endif
|
||||
fgPlatformGlutSetIconTitle ( title );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1137,30 +1201,7 @@ void FGAPIENTRY glutPositionWindow( int x, int y )
|
||||
glutLeaveFullScreen();
|
||||
}
|
||||
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
|
||||
XMoveWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle,
|
||||
x, y );
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
|
||||
#elif TARGET_HOST_MS_WINDOWS
|
||||
|
||||
{
|
||||
RECT winRect;
|
||||
|
||||
/* "GetWindowRect" returns the pixel coordinates of the outside of the window */
|
||||
GetWindowRect( fgStructure.CurrentWindow->Window.Handle, &winRect );
|
||||
MoveWindow(
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
x,
|
||||
y,
|
||||
winRect.right - winRect.left,
|
||||
winRect.bottom - winRect.top,
|
||||
TRUE
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
fgPlatformGlutPositionWindow ( x, y );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1171,20 +1212,7 @@ void FGAPIENTRY glutPushWindow( void )
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPushWindow" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutPushWindow" );
|
||||
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
|
||||
XLowerWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle );
|
||||
|
||||
#elif TARGET_HOST_MS_WINDOWS
|
||||
|
||||
SetWindowPos(
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
HWND_BOTTOM,
|
||||
0, 0, 0, 0,
|
||||
SWP_NOSIZE | SWP_NOMOVE
|
||||
);
|
||||
|
||||
#endif
|
||||
fgPlatformGlutPushWindow ();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1195,20 +1223,7 @@ void FGAPIENTRY glutPopWindow( void )
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPopWindow" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutPopWindow" );
|
||||
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
|
||||
XRaiseWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle );
|
||||
|
||||
#elif TARGET_HOST_MS_WINDOWS
|
||||
|
||||
SetWindowPos(
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
HWND_TOP,
|
||||
0, 0, 0, 0,
|
||||
SWP_NOSIZE | SWP_NOMOVE
|
||||
);
|
||||
|
||||
#endif
|
||||
fgPlatformGlutPopWindow ();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1238,91 +1253,7 @@ void FGAPIENTRY glutFullScreen( void )
|
||||
return;
|
||||
}
|
||||
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
if(!glutGet(GLUT_FULL_SCREEN)) {
|
||||
if(fghToggleFullscreen() != -1) {
|
||||
win->State.IsFullscreen = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#elif TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) /* FIXME: what about WinCE */
|
||||
|
||||
if (glutGet(GLUT_FULL_SCREEN))
|
||||
{
|
||||
/* Leave full screen state before entering fullscreen again (resizing?) */
|
||||
glutLeaveFullScreen();
|
||||
}
|
||||
|
||||
{
|
||||
#if(WINVER >= 0x0500) /* Windows 2000 or later */
|
||||
DWORD s;
|
||||
RECT rect;
|
||||
HMONITOR hMonitor;
|
||||
MONITORINFO mi;
|
||||
|
||||
/* For fullscreen mode, first remove all window decoration
|
||||
* and set style to popup so it will overlap the taskbar
|
||||
* then force to maximize on the screen on which it has the most
|
||||
* overlap.
|
||||
*/
|
||||
|
||||
|
||||
/* store current window rect */
|
||||
GetWindowRect( win->Window.Handle, &win->State.OldRect );
|
||||
|
||||
/* store current window style */
|
||||
win->State.OldStyle = s = GetWindowLong(win->Window.Handle, GWL_STYLE);
|
||||
|
||||
/* remove decorations from style and add popup style*/
|
||||
s &= ~WS_OVERLAPPEDWINDOW;
|
||||
s |= WS_POPUP;
|
||||
SetWindowLong(win->Window.Handle, GWL_STYLE, s);
|
||||
SetWindowPos(win->Window.Handle, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
|
||||
/* 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);
|
||||
mi.cbSize = sizeof(mi);
|
||||
GetMonitorInfo(hMonitor, &mi);
|
||||
rect = mi.rcMonitor;
|
||||
#else /* if (WINVER >= 0x0500) */
|
||||
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 );
|
||||
#endif /* (WINVER >= 0x0500) */
|
||||
|
||||
/*
|
||||
* then resize window
|
||||
* SWP_NOACTIVATE Do not activate the window
|
||||
* SWP_NOOWNERZORDER Do not change position in z-order
|
||||
* SWP_NOSENDCHANGING Suppress WM_WINDOWPOSCHANGING message
|
||||
* SWP_NOZORDER Retains the current Z order (ignore 2nd param)
|
||||
*/
|
||||
SetWindowPos( fgStructure.CurrentWindow->Window.Handle,
|
||||
HWND_TOP,
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.right - rect.left,
|
||||
rect.bottom - rect.top,
|
||||
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
|
||||
SWP_NOZORDER
|
||||
);
|
||||
|
||||
win->State.IsFullscreen = GL_TRUE;
|
||||
}
|
||||
#endif
|
||||
fgPlatformGlutFullScreen ( win );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1337,37 +1268,7 @@ void FGAPIENTRY glutLeaveFullScreen( void )
|
||||
|
||||
win = fgStructure.CurrentWindow;
|
||||
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
if(glutGet(GLUT_FULL_SCREEN)) {
|
||||
if(fghToggleFullscreen() != -1) {
|
||||
win->State.IsFullscreen = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#elif TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) /* FIXME: what about WinCE */
|
||||
if (!glutGet(GLUT_FULL_SCREEN))
|
||||
{
|
||||
/* nothing to do */
|
||||
return;
|
||||
}
|
||||
|
||||
/* restore style of window before making it fullscreen */
|
||||
SetWindowLong(win->Window.Handle, GWL_STYLE, win->State.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,
|
||||
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
|
||||
SWP_NOZORDER
|
||||
);
|
||||
|
||||
win->State.IsFullscreen = GL_FALSE;
|
||||
#endif
|
||||
fgPlatformGlutLeaveFullScreen ( win );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1382,16 +1283,7 @@ void FGAPIENTRY glutFullScreenToggle( void )
|
||||
|
||||
win = fgStructure.CurrentWindow;
|
||||
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
if(fghToggleFullscreen() != -1) {
|
||||
win->State.IsFullscreen = !win->State.IsFullscreen;
|
||||
}
|
||||
#elif TARGET_HOST_MS_WINDOWS
|
||||
if (!win->State.IsFullscreen)
|
||||
glutFullScreen();
|
||||
else
|
||||
glutLeaveFullScreen();
|
||||
#endif
|
||||
fgPlatformGlutFullScreenToggle ( win );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -837,3 +837,232 @@ void fgPlatformCloseWindow( SFG_Window* window )
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This function makes the current window visible
|
||||
*/
|
||||
void fgPlatformGlutShowWindow( void )
|
||||
{
|
||||
ShowWindow( fgStructure.CurrentWindow->Window.Handle, SW_SHOW );
|
||||
}
|
||||
|
||||
/*
|
||||
* This function hides the current window
|
||||
*/
|
||||
void fgPlatformGlutHideWindow( void )
|
||||
{
|
||||
ShowWindow( fgStructure.CurrentWindow->Window.Handle, SW_HIDE );
|
||||
}
|
||||
|
||||
/*
|
||||
* Iconify the current window (top-level windows only)
|
||||
*/
|
||||
void fgPlatformGlutIconifyWindow( void )
|
||||
{
|
||||
ShowWindow( fgStructure.CurrentWindow->Window.Handle, SW_MINIMIZE );
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the current window's title
|
||||
*/
|
||||
void fgPlatformGlutSetWindowTitle( const char* title )
|
||||
{
|
||||
#ifdef _WIN32_WCE
|
||||
{
|
||||
wchar_t* wstr = fghWstrFromStr(title);
|
||||
SetWindowText( fgStructure.CurrentWindow->Window.Handle, wstr );
|
||||
free(wstr);
|
||||
}
|
||||
#else
|
||||
SetWindowText( fgStructure.CurrentWindow->Window.Handle, title );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the current window's iconified title
|
||||
*/
|
||||
void fgPlatformGlutSetIconTitle( const char* title )
|
||||
{
|
||||
#ifdef _WIN32_WCE
|
||||
{
|
||||
wchar_t* wstr = fghWstrFromStr(title);
|
||||
SetWindowText( fgStructure.CurrentWindow->Window.Handle, wstr );
|
||||
free(wstr);
|
||||
}
|
||||
#else
|
||||
SetWindowText( fgStructure.CurrentWindow->Window.Handle, title );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Change the current window's position
|
||||
*/
|
||||
void fgPlatformGlutPositionWindow( int x, int y )
|
||||
{
|
||||
RECT winRect;
|
||||
|
||||
/* "GetWindowRect" returns the pixel coordinates of the outside of the window */
|
||||
GetWindowRect( fgStructure.CurrentWindow->Window.Handle, &winRect );
|
||||
MoveWindow(
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
x,
|
||||
y,
|
||||
winRect.right - winRect.left,
|
||||
winRect.bottom - winRect.top,
|
||||
TRUE
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lowers the current window (by Z order change)
|
||||
*/
|
||||
void fgPlatformGlutPushWindow( void )
|
||||
{
|
||||
SetWindowPos(
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
HWND_BOTTOM,
|
||||
0, 0, 0, 0,
|
||||
SWP_NOSIZE | SWP_NOMOVE
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Raises the current window (by Z order change)
|
||||
*/
|
||||
void fgPlatformGlutPopWindow( void )
|
||||
{
|
||||
SetWindowPos(
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
HWND_TOP,
|
||||
0, 0, 0, 0,
|
||||
SWP_NOSIZE | SWP_NOMOVE
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Resize the current window so that it fits the whole screen
|
||||
*/
|
||||
void fgPlatformGlutFullScreen( SFG_Window *win )
|
||||
{
|
||||
#if !defined(_WIN32_WCE) /* FIXME: what about WinCE */
|
||||
|
||||
if (glutGet(GLUT_FULL_SCREEN))
|
||||
{
|
||||
/* Leave full screen state before entering fullscreen again (resizing?) */
|
||||
glutLeaveFullScreen();
|
||||
}
|
||||
|
||||
{
|
||||
#if(WINVER >= 0x0500) /* Windows 2000 or later */
|
||||
DWORD s;
|
||||
RECT rect;
|
||||
HMONITOR hMonitor;
|
||||
MONITORINFO mi;
|
||||
|
||||
/* For fullscreen mode, first remove all window decoration
|
||||
* and set style to popup so it will overlap the taskbar
|
||||
* then force to maximize on the screen on which it has the most
|
||||
* overlap.
|
||||
*/
|
||||
|
||||
|
||||
/* store current window rect */
|
||||
GetWindowRect( win->Window.Handle, &win->State.OldRect );
|
||||
|
||||
/* store current window style */
|
||||
win->State.OldStyle = s = GetWindowLong(win->Window.Handle, GWL_STYLE);
|
||||
|
||||
/* remove decorations from style and add popup style*/
|
||||
s &= ~WS_OVERLAPPEDWINDOW;
|
||||
s |= WS_POPUP;
|
||||
SetWindowLong(win->Window.Handle, GWL_STYLE, s);
|
||||
SetWindowPos(win->Window.Handle, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
|
||||
/* 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);
|
||||
mi.cbSize = sizeof(mi);
|
||||
GetMonitorInfo(hMonitor, &mi);
|
||||
rect = mi.rcMonitor;
|
||||
#else /* if (WINVER >= 0x0500) */
|
||||
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 );
|
||||
#endif /* (WINVER >= 0x0500) */
|
||||
|
||||
/*
|
||||
* then resize window
|
||||
* SWP_NOACTIVATE Do not activate the window
|
||||
* SWP_NOOWNERZORDER Do not change position in z-order
|
||||
* SWP_NOSENDCHANGING Suppress WM_WINDOWPOSCHANGING message
|
||||
* SWP_NOZORDER Retains the current Z order (ignore 2nd param)
|
||||
*/
|
||||
SetWindowPos( fgStructure.CurrentWindow->Window.Handle,
|
||||
HWND_TOP,
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.right - rect.left,
|
||||
rect.bottom - rect.top,
|
||||
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
|
||||
SWP_NOZORDER
|
||||
);
|
||||
|
||||
win->State.IsFullscreen = GL_TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* If we are fullscreen, resize the current window back to its original size
|
||||
*/
|
||||
void fgPlatformGlutLeaveFullScreen( SFG_Window *win )
|
||||
{
|
||||
#if !defined(_WIN32_WCE) /* FIXME: what about WinCE */
|
||||
if (!glutGet(GLUT_FULL_SCREEN))
|
||||
{
|
||||
/* nothing to do */
|
||||
return;
|
||||
}
|
||||
|
||||
/* restore style of window before making it fullscreen */
|
||||
SetWindowLong(win->Window.Handle, GWL_STYLE, win->State.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,
|
||||
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
|
||||
SWP_NOZORDER
|
||||
);
|
||||
|
||||
win->State.IsFullscreen = GL_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Toggle the window's full screen state.
|
||||
*/
|
||||
void fgPlatformGlutFullScreenToggle( SFG_Window *win )
|
||||
{
|
||||
if (!win->State.IsFullscreen)
|
||||
glutFullScreen();
|
||||
else
|
||||
glutLeaveFullScreen();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user