X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fx11%2Ffg_init_x11.c;h=d2907c9edf967641e44e3df1675503d2deb6340c;hb=2c12c9eb8d63cabac2d4113b4f54fdf53da8368c;hp=6cd6048524f9762ce5b4ab7ea377a60acec0edb8;hpb=0e653a9d94fec583f7a4172b721c1c599e06cbc8;p=freeglut diff --git a/src/x11/fg_init_x11.c b/src/x11/fg_init_x11.c index 6cd6048..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. * @@ -82,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; } @@ -113,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". */ @@ -176,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 ); @@ -216,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"); @@ -236,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;