X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2FCommon%2Ffreeglut_window.c;h=9b28940776113866096d29569c448c9fffbc7593;hb=ee696b7ee5011ba23716abe9ffaeb73c6cfac351;hp=1d409b36c6a9047176fc738f1fc5004a436d1565;hpb=f08f8f9f43e88afba1dd52ca0f79ce9506b81e4f;p=freeglut diff --git a/src/Common/freeglut_window.c b/src/Common/freeglut_window.c index 1d409b3..9b28940 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);} @@ -264,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 ); @@ -286,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 ); @@ -310,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 ); } @@ -324,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 ); @@ -338,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 ); * @@ -402,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 ); @@ -454,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); @@ -467,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, @@ -482,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; @@ -521,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 @@ -553,12 +548,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 @@ -568,25 +563,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; } @@ -614,7 +609,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 ); @@ -632,8 +627,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, @@ -673,7 +668,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'", @@ -712,7 +707,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, @@ -724,11 +719,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 @@ -736,15 +731,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) ); } @@ -754,13 +749,13 @@ 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 */ } @@ -778,8 +773,8 @@ static Bool fghWindowIsVisible( Display *display, XEvent *event, XPointer arg) */ void fgPlatformGlutShowWindow( void ) { - XMapWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle ); - XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */ + XMapWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle ); + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ } /* @@ -788,13 +783,13 @@ void fgPlatformGlutShowWindow( void ) void fgPlatformGlutHideWindow( void ) { if( fgStructure.CurrentWindow->Parent == NULL ) - XWithdrawWindow( fgDisplay.Display, + XWithdrawWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, - fgDisplay.Screen ); + fgDisplay.pDisplay.Screen ); else - XUnmapWindow( fgDisplay.Display, + XUnmapWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle ); - XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */ + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ } /* @@ -802,9 +797,9 @@ void fgPlatformGlutHideWindow( void ) */ void fgPlatformGlutIconifyWindow( void ) { - XIconifyWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle, - fgDisplay.Screen ); - XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */ + XIconifyWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, + fgDisplay.pDisplay.Screen ); + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ } /* @@ -820,12 +815,12 @@ void fgPlatformGlutSetWindowTitle( const char* title ) text.nitems = strlen( title ); XSetWMName( - fgDisplay.Display, + fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, &text ); - XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */ + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ } /* @@ -841,12 +836,12 @@ void fgPlatformGlutSetIconTitle( const char* title ) text.nitems = strlen( title ); XSetWMIconName( - fgDisplay.Display, + fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, &text ); - XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */ + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ } /* @@ -854,9 +849,9 @@ void fgPlatformGlutSetIconTitle( const char* title ) */ void fgPlatformGlutPositionWindow( int x, int y ) { - XMoveWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle, + XMoveWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, x, y ); - XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */ + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ } /* @@ -864,7 +859,7 @@ void fgPlatformGlutPositionWindow( int x, int y ) */ void fgPlatformGlutPushWindow( void ) { - XLowerWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle ); + XLowerWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle ); } /* @@ -872,7 +867,7 @@ void fgPlatformGlutPushWindow( void ) */ void fgPlatformGlutPopWindow( void ) { - XRaiseWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle ); + XRaiseWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle ); } /* @@ -991,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. */