| Summary: | [PATCH] SDL_DisableScreenSaver() not implemented for Win32 | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Cameron Gutman <cameron.gutman> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | flibitijibibo |
| Version: | HG 2.0 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 10 | ||
| Attachments: | Implement WIN_SuspendScreenSaver | ||
Your patch is in, thanks! https://hg.libsdl.org/SDL/rev/e9954c42ee01 One quick comment on this, just saw the commit...
In addition to ThreadExecutionState I also found this as a means of toggling the screensaver; the docs suggest this works as long as the PC isn't in power saving mode or in a locked state:
--------------------------------------------------------------------------------
void SetUp()
{
SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
UINT vParam = 0;
if (SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &vParam, 0))
{
if (vParam == 1)
screenSaverWasEnabled = true;
else
screenSaverWasEnabled = false;
}
if (screenSaverWasEnabled)
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, 0);
}
void TearDown()
{
if (screenSaverWasEnabled)
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, 0, 0);
}
--------------------------------------------------------------------------------
This has been shipping in FEZ for a while, so we know it works, but it's also a pretty aggressive way to do this (you can even set the wallpaper with this function o_o).
|
Created attachment 3358 [details] Implement WIN_SuspendScreenSaver Copying from my attached changeset summary: 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.