From dcb4d8ee325e4ae4ba6804d24dc87f849be0e77b Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 4 Jul 2013 17:52:15 +0200 Subject: [PATCH] Fixed possible X11 screensaver race condition. --- README.md | 2 ++ src/x11_platform.h | 2 +- src/x11_window.c | 12 ++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cf02e601..f3446ebb 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,8 @@ See the [GLFW 3.0 documentation](http://www.glfw.org/docs/3.0/). - [Cocoa] Bugfix: Selectors were used that are not declared by the 10.6 SDK - [X11] Bugfix: Override-redirect windows were resized to the desired instead of the actual resolution of the selected video mode + - [X11] Bugfix: Screensaver override for full screen windows had a possible + race condition ## Contact diff --git a/src/x11_platform.h b/src/x11_platform.h index c669a35e..1ac323dc 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -173,7 +173,7 @@ typedef struct _GLFWlibraryX11 int keyCodeLUT[256]; struct { - GLboolean changed; + int count; int timeout; int interval; int blanking; diff --git a/src/x11_window.c b/src/x11_window.c index 0ff8d043..72c79ab1 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -361,7 +361,7 @@ static void showCursor(_GLFWwindow* window) // static void enterFullscreenMode(_GLFWwindow* window) { - if (!_glfw.x11.saver.changed) + if (_glfw.x11.saver.count == 0) { // Remember old screen saver settings XGetScreenSaver(_glfw.x11.display, @@ -373,10 +373,10 @@ static void enterFullscreenMode(_GLFWwindow* window) // Disable screen saver XSetScreenSaver(_glfw.x11.display, 0, 0, DontPreferBlanking, DefaultExposures); - - _glfw.x11.saver.changed = GL_TRUE; } + _glfw.x11.saver.count++; + _glfwSetVideoMode(window->monitor, &window->videoMode); if (_glfw.x11.hasEWMH && @@ -455,7 +455,9 @@ static void leaveFullscreenMode(_GLFWwindow* window) { _glfwRestoreVideoMode(window->monitor); - if (_glfw.x11.saver.changed) + _glfw.x11.saver.count--; + + if (_glfw.x11.saver.count == 0) { // Restore old screen saver settings XSetScreenSaver(_glfw.x11.display, @@ -463,8 +465,6 @@ static void leaveFullscreenMode(_GLFWwindow* window) _glfw.x11.saver.interval, _glfw.x11.saver.blanking, _glfw.x11.saver.exposure); - - _glfw.x11.saver.changed = GL_FALSE; } if (_glfw.x11.hasEWMH &&