diff --git a/common/include/Utilities/General.h b/common/include/Utilities/General.h index 71a6a58547..f2182e5fad 100644 --- a/common/include/Utilities/General.h +++ b/common/include/Utilities/General.h @@ -254,3 +254,5 @@ extern u64 GetCPUTicks(); extern u64 GetPhysicalMemory(); extern wxString GetOSVersionString(); + +void ScreensaverAllow(bool allow); diff --git a/common/src/Utilities/Linux/LnxMisc.cpp b/common/src/Utilities/Linux/LnxMisc.cpp index 4059bb14e7..4443465119 100644 --- a/common/src/Utilities/Linux/LnxMisc.cpp +++ b/common/src/Utilities/Linux/LnxMisc.cpp @@ -55,3 +55,7 @@ wxString GetOSVersionString() return wxGetOsDescription(); } +void ScreensaverAllow(bool allow) +{ + // no-op +} diff --git a/common/src/Utilities/Windows/WinMisc.cpp b/common/src/Utilities/Windows/WinMisc.cpp index 89a03d08f4..d40e767a34 100644 --- a/common/src/Utilities/Windows/WinMisc.cpp +++ b/common/src/Utilities/Windows/WinMisc.cpp @@ -241,3 +241,10 @@ wxString Exception::WinApiError::FormatDiagnosticMessage() const return m_message_diag + L"\n\t" + GetMsgFromWindows(); } +void ScreensaverAllow(bool allow) +{ + EXECUTION_STATE flags = ES_CONTINUOUS; + if (!allow) + flags |= ES_DISPLAY_REQUIRED; + SetThreadExecutionState(flags); +} diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index 17af2fabb1..9705450f32 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -80,6 +80,7 @@ void GSPanel::InitDefaultAccelerators() GSPanel::GSPanel( wxWindow* parent ) : wxWindow() , m_HideMouseTimer( this ) + , m_coreRunning(false) { m_CursorShown = true; m_HasFocus = false; @@ -312,6 +313,13 @@ void GSPanel::DirectKeyCommand( wxKeyEvent& evt ) DirectKeyCommand(KeyAcceleratorCode( evt )); } +void GSPanel::UpdateScreensaver() +{ + bool prevent = g_Conf->GSWindow.DisableScreenSaver + && m_HasFocus && m_coreRunning; + ScreensaverAllow(!prevent); +} + void GSPanel::OnFocus( wxFocusEvent& evt ) { evt.Skip(); @@ -334,6 +342,8 @@ void GSPanel::OnFocus( wxFocusEvent& evt ) } #endif //Console.Warning("GS frame > focus set"); + + UpdateScreensaver(); } void GSPanel::OnFocusLost( wxFocusEvent& evt ) @@ -350,6 +360,20 @@ void GSPanel::OnFocusLost( wxFocusEvent& evt ) } #endif //Console.Warning("GS frame > focus lost"); + + UpdateScreensaver(); +} + +void GSPanel::CoreThread_OnResumed() +{ + m_coreRunning = true; + UpdateScreensaver(); +} + +void GSPanel::CoreThread_OnSuspended() +{ + m_coreRunning = false; + UpdateScreensaver(); } void GSPanel::AppStatusEvent_OnSettingsApplied() @@ -369,8 +393,6 @@ void GSPanel::OnLeftDclick(wxMouseEvent& evt) DirectKeyCommand(FULLSCREEN_TOGGLE_ACCELERATOR_GSPANEL); } - - // -------------------------------------------------------------------------------------- // GSFrame Implementation // -------------------------------------------------------------------------------------- diff --git a/pcsx2/gui/GSFrame.h b/pcsx2/gui/GSFrame.h index 3563791a7d..58ee80de68 100644 --- a/pcsx2/gui/GSFrame.h +++ b/pcsx2/gui/GSFrame.h @@ -34,6 +34,7 @@ extern LimiterModeType g_LimiterMode; // -------------------------------------------------------------------------------------- class GSPanel : public wxWindow , public EventListener_AppStatus + , public EventListener_CoreThread { typedef wxWindow _parent; @@ -43,6 +44,7 @@ protected: wxTimer m_HideMouseTimer; bool m_CursorShown; bool m_HasFocus; + bool m_coreRunning; public: GSPanel( wxWindow* parent ); @@ -55,11 +57,6 @@ public: protected: void AppStatusEvent_OnSettingsApplied(); - -#ifdef __WXMSW__ - virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); -#endif - void InitDefaultAccelerators(); void OnCloseWindow( wxCloseEvent& evt ); @@ -69,9 +66,12 @@ protected: void OnKeyDown( wxKeyEvent& evt ); void OnFocus( wxFocusEvent& evt ); void OnFocusLost( wxFocusEvent& evt ); + void CoreThread_OnResumed(); + void CoreThread_OnSuspended(); void OnLeftDclick( wxMouseEvent& evt ); + void UpdateScreensaver(); }; diff --git a/pcsx2/gui/MSWstuff.cpp b/pcsx2/gui/MSWstuff.cpp index 70d22cb570..8801cebc5a 100644 --- a/pcsx2/gui/MSWstuff.cpp +++ b/pcsx2/gui/MSWstuff.cpp @@ -54,21 +54,3 @@ void MSW_ListView_SetIconSpacing( wxListbook* listbook, int width ) MSW_ListView_SetIconSpacing( *listbook, width ); } - -#ifdef __WXMSW__ -WXLRESULT GSPanel::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) -{ - switch ( message ) - { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - if( m_HasFocus && g_Conf->GSWindow.DisableScreenSaver) - { - DevCon.WriteLn("Omg Screensaver adverted!"); - return 0; - } - break; - } - return _parent::MSWWindowProc(message, wParam, lParam); -} -#endif