2
0
Эх сурвалжийг харах

Win32: Fix screensaver and blanking prevention

On Vista and later, Handling WM_SYSCOMMAND is not enough to prevent
password protected screensavers or monitor blanking.

Fixes #851.
Camilla Löwy 8 жил өмнө
parent
commit
355b46e6c5

+ 2 - 0
README.md

@@ -149,6 +149,8 @@ information on what to include when reporting a bug.
 - [Win32] Bugfix: Bitness test in `FindVulkan.cmake` was VS specific (#928)
 - [Win32] Bugfix: `glfwVulkanSupported` emitted an error on systems with
                   a loader but no ICD (#916)
+- [Win32] Bugfix: Non-iconified full sreeen windows did not prevent screen
+                  blanking or password enabled screensavers (#851)
 - [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
 - [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X
 - [X11] Bugfix: Dynamic X11 library loading did not use full sonames (#941)

+ 1 - 0
src/win32_platform.h

@@ -248,6 +248,7 @@ typedef struct _GLFWlibraryWin32
 {
     HWND                helperWindowHandle;
     DWORD               foregroundLockTimeout;
+    int                 acquiredMonitorCount;
     char*               clipboardString;
     char                keyName[64];
     short int           keycodes[512];

+ 9 - 0
src/win32_window.c

@@ -422,6 +422,11 @@ static GLFWbool acquireMonitor(_GLFWwindow* window)
     GLFWbool status;
     int xpos, ypos;
 
+    if (!_glfw.win32.acquiredMonitorCount)
+        SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
+    if (!window->monitor->window)
+        _glfw.win32.acquiredMonitorCount++;
+
     status = _glfwSetVideoModeWin32(window->monitor, &window->videoMode);
 
     _glfwPlatformGetVideoMode(window->monitor, &mode);
@@ -442,6 +447,10 @@ static void releaseMonitor(_GLFWwindow* window)
     if (window->monitor->window != window)
         return;
 
+    _glfw.win32.acquiredMonitorCount--;
+    if (!_glfw.win32.acquiredMonitorCount)
+        SetThreadExecutionState(ES_CONTINUOUS);
+
     _glfwInputMonitorWindow(window->monitor, NULL);
     _glfwRestoreVideoModeWin32(window->monitor);
 }