X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2FCommon%2Ffreeglut_window.c;h=cda8115a2b8b80bde846f5de6b4eaa1a4a9d99e5;hb=90f4f27adbf99410b9fa960969bcdba9d42a07cb;hp=802cf07f3319c072da695f32a00be0775891c62b;hpb=cf06fb91082cdf943efeef507086ba1d8cee6eb7;p=freeglut diff --git a/src/Common/freeglut_window.c b/src/Common/freeglut_window.c index 802cf07..cda8115 100644 --- a/src/Common/freeglut_window.c +++ b/src/Common/freeglut_window.c @@ -89,11 +89,6 @@ #endif /* TARGET_HOST_POSIX_X11 */ -#ifdef WM_TOUCH - typedef BOOL (WINAPI *pRegisterTouchWindow)(HWND,ULONG); - static pRegisterTouchWindow fghRegisterTouchWindow = (pRegisterTouchWindow)0xDEADBEEF; -#endif - /* pushing attribute/value pairs into an array */ #define ATTRIB(a) attributes[where++]=(a) #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);} @@ -128,6 +123,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 ---------------------------------------------------- */ @@ -252,8 +259,8 @@ GLXFBConfig* fgChooseFBConfig( int *numcfgs ) /* Get all FBConfigs that match "attributes". */ - fbconfigArray = glXChooseFBConfig( fgDisplay.Display, - fgDisplay.Screen, + fbconfigArray = glXChooseFBConfig( fgDisplay.pDisplay.Display, + fgDisplay.pDisplay.Screen, attributes, &fbconfigArraySize ); @@ -274,13 +281,13 @@ GLXFBConfig* fgChooseFBConfig( int *numcfgs ) /* Get bufferSizeMin. */ result = - glXGetFBConfigAttrib( fgDisplay.Display, + glXGetFBConfigAttrib( fgDisplay.pDisplay.Display, fbconfigArray[0], GLX_BUFFER_SIZE, &bufferSizeMin ); /* Get bufferSizeMax. */ result = - glXGetFBConfigAttrib( fgDisplay.Display, + glXGetFBConfigAttrib( fgDisplay.pDisplay.Display, fbconfigArray[fbconfigArraySize - 1], GLX_BUFFER_SIZE, &bufferSizeMax ); @@ -298,8 +305,8 @@ GLXFBConfig* fgChooseFBConfig( int *numcfgs ) ATTRIB_VAL( GLX_BUFFER_SIZE, bufferSizeMax ); ATTRIB( None ); - fbconfigArray = glXChooseFBConfig( fgDisplay.Display, - fgDisplay.Screen, + fbconfigArray = glXChooseFBConfig( fgDisplay.pDisplay.Display, + fgDisplay.pDisplay.Screen, attributes, &fbconfigArraySize ); } @@ -312,7 +319,7 @@ GLXFBConfig* fgChooseFBConfig( int *numcfgs ) * int fbconfigXID; * * - pick the XID of the FBConfig we want - * result = glXGetFBConfigAttrib( fgDisplay.Display, + * result = glXGetFBConfigAttrib( fgDisplay.pDisplay.Display, * fbconfigArray[0], * GLX_FBCONFIG_ID, * &fbconfigXID ); @@ -326,8 +333,8 @@ GLXFBConfig* fgChooseFBConfig( int *numcfgs ) * ATTRIB( None ); * * - get our FBConfig only - * fbconfig = glXChooseFBConfig( fgDisplay.Display, - * fgDisplay.Screen, + * fbconfig = glXChooseFBConfig( fgDisplay.pDisplay.Display, + * fgDisplay.pDisplay.Screen, * attributes, * &fbconfigArraySize ); * @@ -390,8 +397,8 @@ static GLXContext fghCreateNewContext( SFG_Window* window ) int index_mode = ( fgState.DisplayMode & GLUT_INDEX ); /* "classic" context creation */ - Display *dpy = fgDisplay.Display; - GLXFBConfig config = *(window->Window.FBConfig); + Display *dpy = fgDisplay.pDisplay.Display; + GLXFBConfig config = *(window->Window.pContext.FBConfig); int render_type = ( !menu && index_mode ) ? GLX_COLOR_INDEX_TYPE : GLX_RGBA_TYPE; GLXContext share_list = NULL; Bool direct = ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT ); @@ -442,12 +449,12 @@ 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 */ - XGetWindowAttributes(fgDisplay.Display, + XGetWindowAttributes(fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, &attributes); @@ -455,7 +462,7 @@ static int fghResizeFullscrToggle(void) * The "x" and "y" members of "attributes" are the window's coordinates * relative to its parent, i.e. to the decoration window. */ - XMoveResizeWindow(fgDisplay.Display, + XMoveResizeWindow(fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, -attributes.x, -attributes.y, @@ -470,21 +477,21 @@ static int fghEwmhFullscrToggle(void) XEvent xev; long evmask = SubstructureRedirectMask | SubstructureNotifyMask; - if(!fgDisplay.State || !fgDisplay.StateFullScreen) { + if(!fgDisplay.pDisplay.State || !fgDisplay.pDisplay.StateFullScreen) { return -1; } xev.type = ClientMessage; xev.xclient.window = fgStructure.CurrentWindow->Window.Handle; - xev.xclient.message_type = fgDisplay.State; + xev.xclient.message_type = fgDisplay.pDisplay.State; xev.xclient.format = 32; xev.xclient.data.l[0] = _NET_WM_STATE_TOGGLE; - xev.xclient.data.l[1] = fgDisplay.StateFullScreen; + xev.xclient.data.l[1] = fgDisplay.pDisplay.StateFullScreen; xev.xclient.data.l[2] = 0; /* no second property to toggle */ xev.xclient.data.l[3] = 1; /* source indication: application */ xev.xclient.data.l[4] = 0; /* unused */ - if(!XSendEvent(fgDisplay.Display, fgDisplay.RootWindow, 0, evmask, &xev)) { + if(!XSendEvent(fgDisplay.pDisplay.Display, fgDisplay.pDisplay.RootWindow, 0, evmask, &xev)) { return -1; } return 0; @@ -509,7 +516,7 @@ void fgPlatformSetWindow ( SFG_Window *window ) if ( window ) { glXMakeContextCurrent( - fgDisplay.Display, + fgDisplay.pDisplay.Display, window->Window.Handle, window->Window.Handle, window->Window.Context @@ -518,6 +525,13 @@ void fgPlatformSetWindow ( SFG_Window *window ) } +static Bool fghWindowIsVisible( Display *display, XEvent *event, XPointer arg) +{ + Window window = (Window)arg; + return (event->type == MapNotify) && (event->xmap.window == window); +} + + /* * Opens a window. Requires a SFG_Window object created and attached * to the freeglut structure. OpenGL context is created here. @@ -541,12 +555,12 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, if( window->IsMenu && ( ! fgStructure.MenuContext ) ) fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB ; - window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs ); + window->Window.pContext.FBConfig = fgChooseFBConfig( &num_FBConfigs ); if( window->IsMenu && ( ! fgStructure.MenuContext ) ) fgState.DisplayMode = current_DisplayMode ; - if( ! window->Window.FBConfig ) + if( ! window->Window.pContext.FBConfig ) { /* * The "fgChooseFBConfig" returned a null meaning that the visual @@ -556,25 +570,25 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, if( !( fgState.DisplayMode & GLUT_DOUBLE ) ) { fgState.DisplayMode |= GLUT_DOUBLE ; - window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs ); + window->Window.pContext.FBConfig = fgChooseFBConfig( &num_FBConfigs ); fgState.DisplayMode &= ~GLUT_DOUBLE; } if( fgState.DisplayMode & GLUT_MULTISAMPLE ) { fgState.DisplayMode &= ~GLUT_MULTISAMPLE ; - window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs ); + window->Window.pContext.FBConfig = fgChooseFBConfig( &num_FBConfigs ); fgState.DisplayMode |= GLUT_MULTISAMPLE; } } - FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.FBConfig != NULL, + FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.pContext.FBConfig != NULL, "FBConfig with necessary capabilities not found", "fgOpenWindow" ); /* Get the X visual. */ for (i = 0; i < num_FBConfigs; i++) { - visualInfo = glXGetVisualFromFBConfig( fgDisplay.Display, - window->Window.FBConfig[i] ); + visualInfo = glXGetVisualFromFBConfig( fgDisplay.pDisplay.Display, + window->Window.pContext.FBConfig[i] ); if (visualInfo) break; } @@ -602,7 +616,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, winAttr.border_pixel = 0; winAttr.colormap = XCreateColormap( - fgDisplay.Display, fgDisplay.RootWindow, + fgDisplay.pDisplay.Display, fgDisplay.pDisplay.RootWindow, visualInfo->visual, AllocNone ); @@ -620,8 +634,8 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, w = h = 300; /* default window size */ window->Window.Handle = XCreateWindow( - fgDisplay.Display, - window->Parent == NULL ? fgDisplay.RootWindow : + fgDisplay.pDisplay.Display, + window->Parent == NULL ? fgDisplay.pDisplay.RootWindow : window->Parent->Window.Handle, x, y, w, h, 0, visualInfo->depth, InputOutput, @@ -661,7 +675,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, window->Window.Context = fghCreateNewContext( window ); #if !defined( __FreeBSD__ ) && !defined( __NetBSD__ ) - if( !glXIsDirect( fgDisplay.Display, window->Window.Context ) ) + if( !glXIsDirect( fgDisplay.pDisplay.Display, window->Window.Context ) ) { if( fgState.DirectContext == GLUT_FORCE_DIRECT_CONTEXT ) fgError( "Unable to force direct context rendering for window '%s'", @@ -700,7 +714,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, XStringListToTextProperty( (char **) &title, 1, &textProperty ); XSetWMProperties( - fgDisplay.Display, + fgDisplay.pDisplay.Display, window->Window.Handle, &textProperty, &textProperty, @@ -712,11 +726,11 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, ); XFree( textProperty.value ); - XSetWMProtocols( fgDisplay.Display, window->Window.Handle, - &fgDisplay.DeleteWindow, 1 ); + XSetWMProtocols( fgDisplay.pDisplay.Display, window->Window.Handle, + &fgDisplay.pDisplay.DeleteWindow, 1 ); glXMakeContextCurrent( - fgDisplay.Display, + fgDisplay.pDisplay.Display, window->Window.Handle, window->Window.Handle, window->Window.Context @@ -724,15 +738,15 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, /* register extension events _before_ window is mapped */ #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H - fgRegisterDevices( fgDisplay.Display, &(window->Window.Handle) ); + fgRegisterDevices( fgDisplay.pDisplay.Display, &(window->Window.Handle) ); #endif - XMapWindow( fgDisplay.Display, window->Window.Handle ); + XMapWindow( fgDisplay.pDisplay.Display, window->Window.Handle ); XFree(visualInfo); if( !isSubWindow) - XPeekIfEvent( fgDisplay.Display, &eventReturnBuffer, &fghWindowIsVisible, (XPointer)(window->Window.Handle) ); + XPeekIfEvent( fgDisplay.pDisplay.Display, &eventReturnBuffer, &fghWindowIsVisible, (XPointer)(window->Window.Handle) ); } @@ -742,15 +756,156 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, void fgPlatformCloseWindow( SFG_Window* window ) { if( window->Window.Context ) - glXDestroyContext( fgDisplay.Display, window->Window.Context ); - XFree( window->Window.FBConfig ); + glXDestroyContext( fgDisplay.pDisplay.Display, window->Window.Context ); + XFree( window->Window.pContext.FBConfig ); if( window->Window.Handle ) { - XDestroyWindow( fgDisplay.Display, window->Window.Handle ); + XDestroyWindow( fgDisplay.pDisplay.Display, window->Window.Handle ); } - /* XFlush( fgDisplay.Display ); */ /* XXX Shouldn't need this */ + /* XFlush( fgDisplay.pDisplay.Display ); */ /* XXX Shouldn't need this */ +} + + + + +/* + * This function makes the current window visible + */ +void fgPlatformGlutShowWindow( void ) +{ + XMapWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle ); + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ } +/* + * This function hides the current window + */ +void fgPlatformGlutHideWindow( void ) +{ + if( fgStructure.CurrentWindow->Parent == NULL ) + XWithdrawWindow( fgDisplay.pDisplay.Display, + fgStructure.CurrentWindow->Window.Handle, + fgDisplay.pDisplay.Screen ); + else + XUnmapWindow( fgDisplay.pDisplay.Display, + fgStructure.CurrentWindow->Window.Handle ); + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ +} + +/* + * Iconify the current window (top-level windows only) + */ +void fgPlatformGlutIconifyWindow( void ) +{ + XIconifyWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, + fgDisplay.pDisplay.Screen ); + XFlush( fgDisplay.pDisplay.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.pDisplay.Display, + fgStructure.CurrentWindow->Window.Handle, + &text + ); + + XFlush( fgDisplay.pDisplay.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.pDisplay.Display, + fgStructure.CurrentWindow->Window.Handle, + &text + ); + + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ +} + +/* + * Change the current window's position + */ +void fgPlatformGlutPositionWindow( int x, int y ) +{ + XMoveWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, + x, y ); + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ +} + +/* + * Lowers the current window (by Z order change) + */ +void fgPlatformGlutPushWindow( void ) +{ + XLowerWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle ); +} + +/* + * Raises the current window (by Z order change) + */ +void fgPlatformGlutPopWindow( void ) +{ + XRaiseWindow( fgDisplay.pDisplay.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 +921,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 /* @@ -838,14 +986,6 @@ int FGAPIENTRY glutCreateWindow( const char* title ) GL_FALSE, GL_FALSE )->ID; } -#if TARGET_HOST_MS_WINDOWS -int FGAPIENTRY __glutCreateWindowWithExit( const char *title, void (__cdecl *exit_function)(int) ) -{ - __glutExitFunc = exit_function; - return glutCreateWindow( title ); -} -#endif - /* * This function creates a sub window. */ @@ -955,16 +1095,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 +1108,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 +1122,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 +1137,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 +1151,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 +1188,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 +1199,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 +1210,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 +1240,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 +1255,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 +1270,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 ); } /*