[PATCH] wined3d: Inhibit the screensaver while a full-screen application has focus.

Zebediah Figura zfigura at codeweavers.com
Thu Jul 25 13:12:24 CDT 2019


This matches Windows behaviour at least as of Windows 7.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
Windows does not seem to do it using SystemParametersInfo(), nor using
SetThreadExecutionState(). I suspect it is instead using the Power*Request()
APIs, but as far as I'm aware implementing those would require getting at an
external library such as X11 or dbus from ntdll (or kernel32), which is not
permitted.

 dlls/wined3d/device.c    | 2 ++
 dlls/wined3d/swapchain.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index a4c26cf3976..d37a2169707 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1033,6 +1033,7 @@ HRESULT CDECL wined3d_device_acquire_focus_window(struct wined3d_device *device,
 
     InterlockedExchangePointer((void **)&device->focus_window, window);
     SetWindowPos(window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
+    SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);
 
     return WINED3D_OK;
 }
@@ -1043,6 +1044,7 @@ void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
 
     if (device->focus_window) wined3d_unregister_window(device->focus_window);
     InterlockedExchangePointer((void **)&device->focus_window, NULL);
+    SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, TRUE, NULL, 0);
 }
 
 static void device_init_swapchain_state(struct wined3d_device *device, struct wined3d_swapchain *swapchain)
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 8603c8de7a0..7e35a2f349e 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -1198,6 +1198,8 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa
             ShowWindow(swapchain->device_window, SW_MINIMIZE);
     }
 
+    SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, !activate, NULL, 0);
+
     if (!focus_messages)
         device->filter_messages = filter_messages;
 }
-- 
2.20.1




More information about the wine-devel mailing list