Frame: Extract screensaver-related code into InhibitScreensaver/UninhibitScreensaver

This commit is contained in:
MerryMage
2017-04-09 22:08:52 +01:00
parent 65250c0452
commit c9b2c29ead
3 changed files with 67 additions and 46 deletions

View File

@ -84,10 +84,6 @@
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
#ifdef __APPLE__
#import <IOKit/pwr_mgt/IOPMLib.h>
#endif
class InputConfig;
class wxFrame;
@ -716,26 +712,7 @@ void CFrame::StartGame(const std::string& filename)
}
else
{
#if defined(HAVE_X11) && HAVE_X11
if (SConfig::GetInstance().bDisableScreenSaver)
X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()),
X11Utils::XWindowFromHandle(GetHandle()), true);
#endif
#ifdef _WIN32
// Prevents Windows from sleeping, turning off the display, or idling
EXECUTION_STATE shouldScreenSave =
SConfig::GetInstance().bDisableScreenSaver ? ES_DISPLAY_REQUIRED : 0;
SetThreadExecutionState(ES_CONTINUOUS | shouldScreenSave | ES_SYSTEM_REQUIRED);
#endif
#ifdef __APPLE__
CFStringRef reason_for_activity = CFSTR("Emulation Running");
if (IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn,
reason_for_activity, &m_power_assertion) != kIOReturnSuccess)
{
m_power_assertion = kIOPMNullAssertionID;
}
#endif
InhibitScreensaver();
// We need this specifically to support setting the focus properly when using
// the 'render to main window' feature on Windows
@ -900,23 +877,7 @@ void CFrame::OnStopped()
m_confirmStop = false;
m_tried_graceful_shutdown = false;
#if defined(HAVE_X11) && HAVE_X11
if (SConfig::GetInstance().bDisableScreenSaver)
X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()),
X11Utils::XWindowFromHandle(GetHandle()), false);
#endif
#ifdef _WIN32
// Allow windows to resume normal idling behavior
SetThreadExecutionState(ES_CONTINUOUS);
#endif
#ifdef __APPLE__
if (m_power_assertion != kIOPMNullAssertionID)
{
IOPMAssertionRelease(m_power_assertion);
m_power_assertion = kIOPMNullAssertionID;
}
#endif
UninhibitScreensaver();
m_RenderFrame->SetTitle(StrToWxStr(scm_rev_str));