Merge pull request #5232 from MerryMage/osx-screensaver
Disable screensaver on OS X
This commit is contained in:
commit
ad829ec7a9
|
@ -688,6 +688,64 @@ WXLRESULT CFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void CFrame::InhibitScreensaver()
|
||||||
|
{
|
||||||
|
// 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 (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 should_screen_save =
|
||||||
|
SConfig::GetInstance().bDisableScreenSaver ? ES_DISPLAY_REQUIRED : 0;
|
||||||
|
SetThreadExecutionState(ES_CONTINUOUS | should_screen_save | ES_SYSTEM_REQUIRED);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
if (SConfig::GetInstance().bDisableScreenSaver)
|
||||||
|
{
|
||||||
|
CFStringRef reason_for_activity = CFSTR("Emulation Running");
|
||||||
|
if (IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep,
|
||||||
|
kIOPMAssertionLevelOn, reason_for_activity,
|
||||||
|
&m_power_assertion) != kIOReturnSuccess)
|
||||||
|
{
|
||||||
|
m_power_assertion = kIOPMNullAssertionID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFrame::UninhibitScreensaver()
|
||||||
|
{
|
||||||
|
#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
|
||||||
|
}
|
||||||
|
|
||||||
void CFrame::UpdateTitle(const std::string& str)
|
void CFrame::UpdateTitle(const std::string& str)
|
||||||
{
|
{
|
||||||
if (SConfig::GetInstance().bRenderToMain && SConfig::GetInstance().m_InterfaceStatusbar)
|
if (SConfig::GetInstance().bRenderToMain && SConfig::GetInstance().m_InterfaceStatusbar)
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
#include "UICommon/X11Utils.h"
|
#include "UICommon/X11Utils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// Class declarations
|
// Class declarations
|
||||||
class CGameListCtrl;
|
class CGameListCtrl;
|
||||||
class CCodeWindow;
|
class CCodeWindow;
|
||||||
|
@ -226,6 +230,13 @@ private:
|
||||||
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Screensaver
|
||||||
|
#ifdef __APPLE__
|
||||||
|
IOPMAssertionID m_power_assertion = kIOPMNullAssertionID;
|
||||||
|
#endif
|
||||||
|
void InhibitScreensaver();
|
||||||
|
void UninhibitScreensaver();
|
||||||
|
|
||||||
void DoOpen(bool Boot);
|
void DoOpen(bool Boot);
|
||||||
void DoPause();
|
void DoPause();
|
||||||
void DoToggleToolbar(bool);
|
void DoToggleToolbar(bool);
|
||||||
|
|
|
@ -721,18 +721,7 @@ void CFrame::StartGame(const std::string& filename)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(HAVE_X11) && HAVE_X11
|
InhibitScreensaver();
|
||||||
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
|
|
||||||
|
|
||||||
// We need this specifically to support setting the focus properly when using
|
// We need this specifically to support setting the focus properly when using
|
||||||
// the 'render to main window' feature on Windows
|
// the 'render to main window' feature on Windows
|
||||||
|
@ -904,16 +893,7 @@ void CFrame::OnStopped()
|
||||||
m_confirm_stop = false;
|
m_confirm_stop = false;
|
||||||
m_tried_graceful_shutdown = false;
|
m_tried_graceful_shutdown = false;
|
||||||
|
|
||||||
#if defined(HAVE_X11) && HAVE_X11
|
UninhibitScreensaver();
|
||||||
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
|
|
||||||
|
|
||||||
m_render_frame->SetTitle(StrToWxStr(scm_rev_str));
|
m_render_frame->SetTitle(StrToWxStr(scm_rev_str));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue