mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Clean up screen saver inhibition and apply setting change immediately.
This commit is contained in:
@ -397,57 +397,42 @@ bool TriggerSTMPowerEvent()
|
||||
}
|
||||
|
||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||
void EnableScreenSaver(Window win, bool enable)
|
||||
void InhibitScreenSaver(Window win, bool inhibit)
|
||||
#else
|
||||
void EnableScreenSaver(bool enable)
|
||||
void InhibitScreenSaver(bool inhibit)
|
||||
#endif
|
||||
{
|
||||
// Inhibit the screensaver. Depending on the operating system this may also
|
||||
// disable low-power states and/or screen dimming.
|
||||
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
if (Config::Get(Config::MAIN_DISABLE_SCREENSAVER))
|
||||
{
|
||||
X11Utils::InhibitScreensaver(win, !enable);
|
||||
}
|
||||
X11Utils::InhibitScreensaver(win, inhibit);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
// Prevents Windows from sleeping, turning off the display, or idling
|
||||
if (enable)
|
||||
{
|
||||
SetThreadExecutionState(ES_CONTINUOUS);
|
||||
}
|
||||
else
|
||||
{
|
||||
EXECUTION_STATE should_screen_save =
|
||||
Config::Get(Config::MAIN_DISABLE_SCREENSAVER) ? ES_DISPLAY_REQUIRED : 0;
|
||||
SetThreadExecutionState(ES_CONTINUOUS | should_screen_save | ES_SYSTEM_REQUIRED);
|
||||
}
|
||||
SetThreadExecutionState(ES_CONTINUOUS |
|
||||
(inhibit ? (ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED) : 0));
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
static IOPMAssertionID s_power_assertion = kIOPMNullAssertionID;
|
||||
|
||||
if (Config::Get(Config::MAIN_DISABLE_SCREENSAVER))
|
||||
if (inhibit)
|
||||
{
|
||||
if (enable)
|
||||
CFStringRef reason_for_activity = CFSTR("Emulation Running");
|
||||
if (IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep,
|
||||
kIOPMAssertionLevelOn, reason_for_activity,
|
||||
&s_power_assertion) != kIOReturnSuccess)
|
||||
{
|
||||
if (s_power_assertion != kIOPMNullAssertionID)
|
||||
{
|
||||
IOPMAssertionRelease(s_power_assertion);
|
||||
s_power_assertion = kIOPMNullAssertionID;
|
||||
}
|
||||
s_power_assertion = kIOPMNullAssertionID;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s_power_assertion != kIOPMNullAssertionID)
|
||||
{
|
||||
CFStringRef reason_for_activity = CFSTR("Emulation Running");
|
||||
if (IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep,
|
||||
kIOPMAssertionLevelOn, reason_for_activity,
|
||||
&s_power_assertion) != kIOReturnSuccess)
|
||||
{
|
||||
s_power_assertion = kIOPMNullAssertionID;
|
||||
}
|
||||
IOPMAssertionRelease(s_power_assertion);
|
||||
s_power_assertion = kIOPMNullAssertionID;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user