Skip to content

Commit

Permalink
Implement SuspendScreenSaver for Win32
Browse files Browse the repository at this point in the history
Creating a full-screen SDL renderer on Windows will keep the screensaver
suspended by DirectX, as is default for full-screen DX applications. However,
for applications that render in windowed-mode, the screensaver will
still kick in, even if SDL_DisableScreenSaver() is called or
SDL_HINT_VIDEO_ALLOW_SCREENSAVER is set to 0 (default). Implementing
a SuspendScreenSaver() function for Win32 fixes this behavior.
  • Loading branch information
cgutman committed Oct 10, 2018
1 parent 04cbf13 commit eff5f65
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/video/windows/SDL_windowsvideo.c
Expand Up @@ -63,6 +63,15 @@ UpdateWindowFrameUsableWhileCursorHidden(void *userdata, const char *name, const
}
}

static void WIN_SuspendScreenSaver(_THIS)
{
if (_this->suspend_screensaver) {
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
} else {
SetThreadExecutionState(ES_CONTINUOUS);
}
}


/* Windows driver bootstrap functions */

Expand Down Expand Up @@ -136,6 +145,7 @@ WIN_CreateDevice(int devindex)
device->GetDisplayModes = WIN_GetDisplayModes;
device->SetDisplayMode = WIN_SetDisplayMode;
device->PumpEvents = WIN_PumpEvents;
device->SuspendScreenSaver = WIN_SuspendScreenSaver;

device->CreateSDLWindow = WIN_CreateWindow;
device->CreateSDLWindowFrom = WIN_CreateWindowFrom;
Expand Down

0 comments on commit eff5f65

Please sign in to comment.