mirror of https://github.com/PCSX2/pcsx2.git
fix: disable screen saver (pcsx2_ui.ini - DisableScreenSaver)
there was already code for this, but it was broken due to: - the message is WM_SYSCOMMAND and wParam is SC_SCREENSAVE etc. - GSPanel doesn't get WM_SYSCOMMAND - GSFrame does. - also disabled screen saver while paused if not set to hide the GS window. - it's an ugly hack where windows keeps trying to activate the screen saver every few seconds but such code prevents it (Lilypad has the same hack). the new code uses windows API which was designed for this. the screen saver is now disabled while the window is focused and the emulation is running. it's on by defauly and without GUI - the same as with normal games. this patch addresses Windows only, but adds a placeholder for future implementations for other platforms.
This commit is contained in:
parent
3c84e6848b
commit
8a5c8ab91c
|
@ -254,3 +254,5 @@ extern u64 GetCPUTicks();
|
|||
extern u64 GetPhysicalMemory();
|
||||
|
||||
extern wxString GetOSVersionString();
|
||||
|
||||
void ScreensaverAllow(bool allow);
|
||||
|
|
|
@ -55,3 +55,7 @@ wxString GetOSVersionString()
|
|||
return wxGetOsDescription();
|
||||
}
|
||||
|
||||
void ScreensaverAllow(bool allow)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue