diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index e5453efe4a..e7a821bfe8 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -23,6 +23,10 @@ #include "UICommon/X11Utils.h" #endif +#ifdef __APPLE__ +#import +#endif + // Class declarations class CGameListCtrl; class CCodeWindow; @@ -160,6 +164,10 @@ private: ADD_PANE_CENTER }; +#ifdef __APPLE__ + IOPMAssertionID m_power_assertion = kIOPMNullAssertionID; +#endif + wxTimer m_poll_hotkey_timer; wxTimer m_handle_signal_timer; 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 +#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));