summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX/FrameTools.cpp
diff options
context:
space:
mode:
authorSalehen Shovon Rahman <salehen.rahman@gmail.com>2016-12-17 20:40:03 -0800
committerMerryMage <MerryMage@users.noreply.github.com>2017-04-09 15:16:52 +0100
commit65250c0452292b7cf1c5fcfbfc9ab5f1945dcf3a (patch)
treeffb87bfc30f9d598305ef30a263064e31558258d /Source/Core/DolphinWX/FrameTools.cpp
parent188f2b3cc52266909c6729e5f31d8f9620eb08f8 (diff)
Disable screensaver on OS X
When playing a game on OS X, although the screen does not go to sleep, the screensaver is still enabled, and therefore, during gameplay, the screensaver may start running, which is not in accordance to the behaviour on other other environments (Windows and X11). It can be argued that the screensaver interrupting gameplay is a nuissance to many players. The changes in this commit are intended to allow Dolphin to disable the screensaver during gameplay, just as intended on other platforms. The changes have been tested on OS X 10.11 (El Capitan).
Diffstat (limited to 'Source/Core/DolphinWX/FrameTools.cpp')
-rw-r--r--Source/Core/DolphinWX/FrameTools.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp
index 608141e94e..6ce69b42c8 100644
--- a/Source/Core/DolphinWX/FrameTools.cpp
+++ b/Source/Core/DolphinWX/FrameTools.cpp
@@ -84,6 +84,10 @@
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
+#ifdef __APPLE__
+#import <IOKit/pwr_mgt/IOPMLib.h>
+#endif
+
class InputConfig;
class wxFrame;
@@ -724,6 +728,14 @@ void CFrame::StartGame(const std::string& filename)
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
// We need this specifically to support setting the focus properly when using
// the 'render to main window' feature on Windows
@@ -898,6 +910,13 @@ void CFrame::OnStopped()
// 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
m_RenderFrame->SetTitle(StrToWxStr(scm_rev_str));