From 62e790f10992bc0e03fce52b59cde5e38adf44b8 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Thu, 25 Aug 2011 14:44:13 -0500 Subject: [PATCH] Have the ability to disable screensaver due to Nvidia + Displayport can cause annoying flickering Bring up to standards guidelines and also support Windows Switch this around... --- Source/Core/Core/Src/ConfigManager.cpp | 2 ++ Source/Core/Core/Src/CoreParameter.cpp | 2 +- Source/Core/Core/Src/CoreParameter.h | 2 +- Source/Core/DolphinWX/Src/Frame.cpp | 2 +- Source/Core/DolphinWX/Src/FrameTools.cpp | 2 ++ Source/Core/DolphinWX/Src/MainNoGUI.cpp | 7 ++++--- Source/Core/VideoCommon/Src/EmuWindow.cpp | 2 ++ 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index d91fa318d7..7b0716a3eb 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -191,6 +191,7 @@ void SConfig::SaveSettings() ini.Set("Display", "RenderWindowHeight", m_LocalCoreStartupParameter.iRenderWindowHeight); ini.Set("Display", "RenderWindowAutoSize", m_LocalCoreStartupParameter.bRenderWindowAutoSize); ini.Set("Display", "ProgressiveScan", m_LocalCoreStartupParameter.bProgressive); + ini.Set("Display", "DisableScreenSaver", m_LocalCoreStartupParameter.bDisableScreenSaver); ini.Set("Display", "ForceNTSCJ", m_LocalCoreStartupParameter.bForceNTSCJ); // Game List Control @@ -320,6 +321,7 @@ void SConfig::LoadSettings() ini.Get("Display", "RenderWindowHeight", &m_LocalCoreStartupParameter.iRenderWindowHeight, 480); ini.Get("Display", "RenderWindowAutoSize", &m_LocalCoreStartupParameter.bRenderWindowAutoSize, false); ini.Get("Display", "ProgressiveScan", &m_LocalCoreStartupParameter.bProgressive, false); + ini.Get("Display", "DisableScreenSaver", &m_LocalCoreStartupParameter.bDisableScreenSaver, true); ini.Get("Display", "ForceNTSCJ", &m_LocalCoreStartupParameter.bForceNTSCJ, false); // Game List Control diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index 49a9ea2992..c608905e39 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -59,7 +59,7 @@ SCoreStartupParameter::SCoreStartupParameter() iRenderWindowWidth(640), iRenderWindowHeight(480), bRenderWindowAutoSize(false), bFullscreen(false), bRenderToMain(false), - bProgressive(false), + bProgressive(false), bDisableScreenSaver(false), iTheme(0), iPosX(100), iPosY(100), iWidth(800), iHeight(600) { diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index 9c5b815794..af885efcad 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -135,7 +135,7 @@ struct SCoreStartupParameter int iRenderWindowWidth, iRenderWindowHeight; bool bRenderWindowAutoSize; bool bFullscreen, bRenderToMain; - bool bProgressive; + bool bProgressive, bDisableScreenSaver; int iTheme; int iPosX, iPosY, iWidth, iHeight; diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 28e9bbfebd..261d3d6d6d 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -201,7 +201,7 @@ WXLRESULT CRenderFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPa { case SC_SCREENSAVE: case SC_MONITORPOWER: - if (Core::GetState() == Core::CORE_RUN) + if (Core::GetState() == Core::CORE_RUN && SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver) break; default: return wxFrame::MSWWindowProc(nMsg, wParam, lParam); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index a3798fe084..be24228c98 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -950,6 +950,7 @@ void CFrame::StartGame(const std::string& filename) else { #if defined(HAVE_X11) && HAVE_X11 + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver) X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()), X11Utils::XWindowFromHandle(GetHandle()), true); #endif @@ -1070,6 +1071,7 @@ void CFrame::DoStop() wxEndBusyCursor(); #if defined(HAVE_X11) && HAVE_X11 + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver) X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()), X11Utils::XWindowFromHandle(GetHandle()), false); #endif diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index ffb511dc70..a37406bbf6 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -146,7 +146,8 @@ void X11_MainLoop() Window win = (Window)Core::GetWindowHandle(); XSelectInput(dpy, win, KeyPressMask | FocusChangeMask); - X11Utils::InhibitScreensaver(dpy, win, true); + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver) + X11Utils::InhibitScreensaver(dpy, win, true); #if defined(HAVE_XRANDR) && HAVE_XRANDR X11Utils::XRRConfiguration *XRRConfig = new X11Utils::XRRConfiguration(dpy, win); @@ -258,8 +259,8 @@ void X11_MainLoop() #if defined(HAVE_XRANDR) && HAVE_XRANDR delete XRRConfig; #endif - - X11Utils::InhibitScreensaver(dpy, win, false); + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver) + X11Utils::InhibitScreensaver(dpy, win, false); if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) XFreeCursor(dpy, blankCursor); diff --git a/Source/Core/VideoCommon/Src/EmuWindow.cpp b/Source/Core/VideoCommon/Src/EmuWindow.cpp index dbd223c368..fef959f1c2 100644 --- a/Source/Core/VideoCommon/Src/EmuWindow.cpp +++ b/Source/Core/VideoCommon/Src/EmuWindow.cpp @@ -209,10 +209,12 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) // Called when a screensaver wants to show up while this window is active case WM_SYSCOMMAND: + switch (wParam) { case SC_SCREENSAVE: case SC_MONITORPOWER: + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver) break; default: return DefWindowProc(hWnd, iMsg, wParam, lParam);