We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4302 - [PATCH] SDL_DisableScreenSaver() not implemented for Win32
Summary: [PATCH] SDL_DisableScreenSaver() not implemented for Win32
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 Windows 10
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-10 06:10 UTC by Cameron Gutman
Modified: 2018-10-11 15:25 UTC (History)
1 user (show)

See Also:


Attachments
Implement WIN_SuspendScreenSaver (1.51 KB, text/plain)
2018-10-10 06:10 UTC, Cameron Gutman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron Gutman 2018-10-10 06:10:48 UTC
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.
Comment 1 Sam Lantinga 2018-10-11 05:48:40 UTC
Your patch is in, thanks!
https://hg.libsdl.org/SDL/rev/e9954c42ee01
Comment 2 Ethan Lee 2018-10-11 15:25:11 UTC
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).