Commit 236f590f authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

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

This matches Windows behaviour at least as of Windows 7. Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 14dee7bd
......@@ -912,6 +912,8 @@ static void destroy_default_samplers(struct wined3d_device *device, struct wined
HRESULT CDECL wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window)
{
unsigned int screensaver_active;
TRACE("device %p, window %p.\n", device, window);
if (!wined3d_register_window(NULL, window, device, 0))
......@@ -922,6 +924,9 @@ 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_GETSCREENSAVEACTIVE, 0, &screensaver_active, 0);
if ((device->restore_screensaver = !!screensaver_active))
SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);
return WINED3D_OK;
}
......@@ -932,6 +937,11 @@ 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);
if (device->restore_screensaver)
{
SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, TRUE, NULL, 0);
device->restore_screensaver = FALSE;
}
}
static void device_init_swapchain_state(struct wined3d_device *device, struct wined3d_swapchain *swapchain)
......
......@@ -1172,6 +1172,7 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa
{
struct wined3d_device *device = swapchain->device;
HWND window = swapchain->state.device_window;
unsigned int screensaver_active;
BOOL focus_messages, filter;
/* This code is not protected by the wined3d mutex, so it may run while
......@@ -1184,6 +1185,10 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa
if (activate)
{
SystemParametersInfoW(SPI_GETSCREENSAVEACTIVE, 0, &screensaver_active, 0);
if ((device->restore_screensaver = !!screensaver_active))
SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);
if (!(device->create_parms.flags & WINED3DCREATE_NOWINDOWCHANGES))
{
/* The d3d versions do not agree on the exact messages here. D3d8 restores
......@@ -1209,6 +1214,12 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa
}
else
{
if (device->restore_screensaver)
{
SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, TRUE, NULL, 0);
device->restore_screensaver = FALSE;
}
if (FAILED(wined3d_set_adapter_display_mode(device->wined3d,
device->adapter->ordinal, NULL)))
ERR("Failed to set display mode.\n");
......
......@@ -3180,7 +3180,8 @@ struct wined3d_device
BYTE d3d_initialized : 1;
BYTE inScene : 1; /* A flag to check for proper BeginScene / EndScene call pairs */
BYTE softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
BYTE padding : 4;
BYTE restore_screensaver : 1;
BYTE padding : 3;
unsigned char surface_alignment; /* Line Alignment of surfaces */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment