added: periodically call XResetScreenSaver() when fullscreen since SDL doesn't do...
authorbobo1on1 <bobo1on1@svn>
Fri, 24 Dec 2010 23:35:08 +0000 (23:35 +0000)
committertheuni <theuni-nospam-@xbmc.org>
Sat, 22 Jan 2011 18:10:32 +0000 (13:10 -0500)
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@35689 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
(cherry picked from commit 213a51016197c4cbb41ed2247cf48cbce135f64b)

xbmc/Application.cpp
xbmc/WinSystemX11.cpp
xbmc/WinSystemX11.h

index a7bf094..269acbb 100644 (file)
@@ -557,7 +557,9 @@ bool CApplication::Create()
   //depending on how it's compiled, SDL periodically calls XResetScreenSaver when it's fullscreen
   //this might bring the monitor out of standby, so we have to disable it explicitly
   //by passing 0 for overwrite to setsenv, the user can still override this by setting the environment variable
+#if defined(_LINUX) && !defined(__APPLE__)
   setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
+#endif
 
 #endif // HAS_SDL
 
@@ -4244,6 +4246,11 @@ bool CApplication::WakeUpScreenSaver()
 
 void CApplication::CheckScreenSaverAndDPMS()
 {
+#if defined(_LINUX) && !defined(__APPLE__)
+  if (!m_dpmsIsActive)
+    g_Windowing.ResetX11Screensaver();
+#endif
+
   bool maybeScreensaver =
       !m_dpmsIsActive && !m_bScreenSave
       && !g_guiSettings.GetString("screensaver.mode").IsEmpty();
index 6e75ec5..e833417 100644 (file)
@@ -34,7 +34,7 @@
 
 using namespace std;
 
-CWinSystemX11::CWinSystemX11() : CWinSystemBase()
+CWinSystemX11::CWinSystemX11() : CWinSystemBase(), m_screensaverReset(true)
 {
   m_eWindowSystem = WINDOW_SYSTEM_X11;
   m_glContext = NULL;
@@ -385,6 +385,27 @@ void CWinSystemX11::ShowOSMouse(bool show)
   SDL_ShowCursor(show ? 1 : 0);
 }
 
+void CWinSystemX11::ResetX11Screensaver()
+{
+  if (m_bFullScreen)
+  {
+    //disallow the screensaver when we're fullscreen by periodically calling XResetScreenSaver(),
+    //normally SDL does this but we disable that in CApplication::Create()
+    //for some reason setting a 0 timeout with XSetScreenSaver doesn't work with gnome
+    if (!m_screensaverReset.IsRunning() || m_screensaverReset.GetElapsedSeconds() > 5.0f)
+    {
+      m_screensaverReset.StartZero();
+      XResetScreenSaver(m_dpy);
+      //need to flush the output buffer, since we don't check for events on m_dpy
+      XFlush(m_dpy);
+    }
+  }
+  else
+  {
+    m_screensaverReset.Stop();
+  }
+}
+
 void CWinSystemX11::NotifyAppActiveChange(bool bActivated)
 {
   if (bActivated && m_bWasFullScreenBeforeMinimize && !g_graphicsContext.IsFullScreenRoot())
index e181b57..7d2da0f 100644 (file)
@@ -24,6 +24,7 @@
  *
  */
 #include "WinSystem.h"
+#include "utils/Stopwatch.h"
 #include <GL/glx.h>
 
 class CWinSystemX11 : public CWinSystemBase
@@ -42,6 +43,7 @@ public:
   virtual void UpdateResolutions();
   virtual int  GetNumScreens() { return 1; }
   virtual void ShowOSMouse(bool show);
+  virtual void ResetX11Screensaver();
 
   virtual void NotifyAppActiveChange(bool bActivated);
 
@@ -66,6 +68,8 @@ protected:
 
 private:
   bool IsSuitableVisual(XVisualInfo *vInfo);
+
+  CStopWatch m_screensaverReset;
 };
 
 #endif // WINDOW_SYSTEM_H