diff --git a/src/x11_gamma.c b/src/x11_gamma.c index c3791afc..1ca0a8c1 100644 --- a/src/x11_gamma.c +++ b/src/x11_gamma.c @@ -90,6 +90,17 @@ void _glfwInitGammaRamp(void) } +//======================================================================== +// Restore original gamma ramp if necessary +//======================================================================== + +void _glfwTerminateGammaRamp(void) +{ + if (_glfwLibrary.originalRampSize && _glfwLibrary.rampChanged) + _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp); +} + + ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// diff --git a/src/x11_init.c b/src/x11_init.c index 3543c9f5..3cb94e54 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -659,9 +659,6 @@ static Cursor createNULLCursor(void) static void terminateDisplay(void) { - if (_glfwLibrary.originalRampSize && _glfwLibrary.rampChanged) - _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp); - if (_glfwLibrary.X11.display) { XCloseDisplay(_glfwLibrary.X11.display); @@ -713,6 +710,8 @@ int _glfwPlatformTerminate(void) _glfwLibrary.X11.cursor = (Cursor) 0; } + _glfwTerminateGammaRamp(); + terminateDisplay(); _glfwTerminateJoysticks(); diff --git a/src/x11_platform.h b/src/x11_platform.h index e4fbfe08..4cb20668 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -285,6 +285,7 @@ void _glfwInitTimer(void); // Gamma void _glfwInitGammaRamp(void); +void _glfwTerminateGammaRamp(void); // Fullscreen support int _glfwGetClosestVideoMode(int* width, int* height, int* rate);