X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fx11%2Ffg_init_x11.c;h=d2907c9edf967641e44e3df1675503d2deb6340c;hb=207c3128bf025b5e025bace5c0425d380dd72aa9;hp=45ac0d17477b0bed8708ae0b6a2b7ae3a55cee15;hpb=b744f1401b990f642e96d4c65cc86eca5224efd1;p=freeglut diff --git a/src/x11/fg_init_x11.c b/src/x11/fg_init_x11.c index 45ac0d1..d2907c9 100644 --- a/src/x11/fg_init_x11.c +++ b/src/x11/fg_init_x11.c @@ -1,5 +1,5 @@ /* - * freeglut_init_x11.c + * fg_init_x11.c * * Various freeglut initialization functions. * @@ -29,7 +29,9 @@ #define FREEGLUT_BUILDING_LIB #include /* LONG_MAX */ #include -#include "../fg_internal.h" +#include "fg_internal.h" +#include "fg_init.h" +#include "egl/fg_init_egl.h" /* Return the atom associated with "name". */ static Atom fghGetAtom(const char * name) @@ -80,9 +82,9 @@ static int fghGetWindowProperty(Window window, "fghGetWindowProperty"); if (type_returned != type) - { - number_of_elements = 0; - } + { + number_of_elements = 0; + } return number_of_elements; } @@ -111,30 +113,30 @@ static int fghNetWMSupported(void) XA_WINDOW, (unsigned char **) window_ptr_1); if (number_of_windows == 1) - { - Window ** window_ptr_2; - - window_ptr_2 = malloc(sizeof(Window *)); + { + Window ** window_ptr_2; - /* Check that the window has the same property set to the same value. */ - number_of_windows = fghGetWindowProperty(**window_ptr_1, - wm_check, - XA_WINDOW, - (unsigned char **) window_ptr_2); - if ((number_of_windows == 1) && (**window_ptr_1 == **window_ptr_2)) - { - /* NET WM compliant */ - net_wm_supported = 1; - } + window_ptr_2 = malloc(sizeof(Window *)); - XFree(*window_ptr_2); - free(window_ptr_2); + /* Check that the window has the same property set to the same value. */ + number_of_windows = fghGetWindowProperty(**window_ptr_1, + wm_check, + XA_WINDOW, + (unsigned char **) window_ptr_2); + if ((number_of_windows == 1) && (**window_ptr_1 == **window_ptr_2)) + { + /* NET WM compliant */ + net_wm_supported = 1; } - XFree(*window_ptr_1); - free(window_ptr_1); + XFree(*window_ptr_2); + free(window_ptr_2); + } + + XFree(*window_ptr_1); + free(window_ptr_1); - return net_wm_supported; + return net_wm_supported; } /* Check if "hint" is present in "property" for "window". */ @@ -174,12 +176,23 @@ void fgPlatformInitialize( const char* displayName ) if( fgDisplay.pDisplay.Display == NULL ) fgError( "failed to open display '%s'", XDisplayName( displayName ) ); + if ( fgState.XSyncSwitch ) + XSynchronize(fgDisplay.pDisplay.Display, True); + #ifdef EGL_VERSION_1_0 fghPlatformInitializeEGL(); #else if( !glXQueryExtension( fgDisplay.pDisplay.Display, NULL, NULL ) ) fgError( "OpenGL GLX extension not supported by display '%s'", XDisplayName( displayName ) ); + + /* This forces AMD Catalyst drivers to initialize and register a shutdown + * function, which must be done before our own call to atexit to prevent + * a crash if glutMainLoop is not called or is not exited cleanly. + * (see bug #206) + */ + glXQueryExtensionsString( fgDisplay.pDisplay.Display, + DefaultScreen( fgDisplay.pDisplay.Display )); #endif fgDisplay.pDisplay.Screen = DefaultScreen( fgDisplay.pDisplay.Display ); @@ -214,8 +227,12 @@ void fgPlatformInitialize( const char* displayName ) /* Create the state and full screen atoms */ fgDisplay.pDisplay.State = None; fgDisplay.pDisplay.StateFullScreen = None; + fgDisplay.pDisplay.NetWMPid = None; + fgDisplay.pDisplay.ClientMachine = None; - if (fghNetWMSupported()) + fgDisplay.pDisplay.NetWMSupported = fghNetWMSupported(); + + if (fgDisplay.pDisplay.NetWMSupported) { const Atom supported = fghGetAtom("_NET_SUPPORTED"); const Atom state = fghGetAtom("_NET_WM_STATE"); @@ -234,8 +251,14 @@ void fgPlatformInitialize( const char* displayName ) fgDisplay.pDisplay.StateFullScreen = full_screen; } } + + fgDisplay.pDisplay.NetWMPid = fghGetAtom("_NET_WM_PID"); + fgDisplay.pDisplay.ClientMachine = fghGetAtom("WM_CLIENT_MACHINE"); } + /* Get start time */ + fgState.Time = fgSystemTime(); + fgState.Initialised = GL_TRUE;