summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej@ahunt.org>2015-10-19 21:50:39 +0200
committerAndrzej Hunt <andrzej@ahunt.org>2015-10-20 18:14:40 +0200
commit189aabbcde1fe544a4e98ab9ee82aea03f1e00f3 (patch)
tree15dd8a9ddb4f525c802ded4d9fc8398a63ace9fa /vcl
parent5074d1b4d712cd35798758e8168ffbdfe59a11a9 (diff)
Deduplicate XGet/SetScreenSaver, move to ScreenSaverInhibitor
I haven't been able to find anyone actually using this API, however it's probably best not to remove it either? Change-Id: I0ca11591bfd54f9882d8081a94b012f638936ce5
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/unx/gtk/gtkframe.hxx1
-rw-r--r--vcl/inc/unx/salframe.h1
-rw-r--r--vcl/inc/unx/screensaverinhibitor.hxx3
-rw-r--r--vcl/unx/generic/window/salframe.cxx28
-rw-r--r--vcl/unx/generic/window/screensaverinhibitor.cxx32
-rw-r--r--vcl/unx/gtk/window/gtksalframe.cxx34
6 files changed, 36 insertions, 63 deletions
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index e6cdbd758a4a..4f73ac8fc2d0 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -192,7 +192,6 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider
GdkCursor *m_pCurrentCursor;
GdkVisibilityState m_nVisibility;
PointerStyle m_ePointerStyle;
- int m_nSavedScreenSaverTimeout;
ScreenSaverInhibitor m_ScreenSaverInhibitor;
int m_nWorkArea;
bool m_bFullscreen;
diff --git a/vcl/inc/unx/salframe.h b/vcl/inc/unx/salframe.h
index b10bebd6c16b..d595c441bd26 100644
--- a/vcl/inc/unx/salframe.h
+++ b/vcl/inc/unx/salframe.h
@@ -100,7 +100,6 @@ class VCLPLUG_GEN_PUBLIC X11SalFrame : public SalFrame, public X11WindowProvider
int m_nWorkArea;
bool m_bSetFocusOnMap;
- int nScreenSaversTimeout_;
ScreenSaverInhibitor maScreenSaverInhibitor;
Rectangle maPaintRegion;
diff --git a/vcl/inc/unx/screensaverinhibitor.hxx b/vcl/inc/unx/screensaverinhibitor.hxx
index 56d184943cf4..8c9ad54f6044 100644
--- a/vcl/inc/unx/screensaverinhibitor.hxx
+++ b/vcl/inc/unx/screensaverinhibitor.hxx
@@ -30,10 +30,13 @@ private:
boost::optional<guint> mnFDOCookie;
boost::optional<guint> mnGSMCookie;
+ boost::optional<int> mnXScreenSaverTimeout;
+
// Note: the Uninhibit call has different spelling in FDO (UnInhibit) vs GSM (Uninhibit)
void inhibitFDO( bool bInhibit, const gchar* appname, const gchar* reason );
void inhibitGSM( bool bInhibit, const gchar* appname, const gchar* reason, const guint xid );
+ void inhibitXScreenSaver( bool bInhibit, Display* pDisplay );
static void inhibitXAutoLock( bool bInhibit, Display* pDisplay );
};
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 331f82af845d..c1122f7a6919 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -803,7 +803,6 @@ X11SalFrame::X11SalFrame( SalFrame *pParent, SalFrameStyleFlags nSalFrameStyle,
mbInShow = false;
m_bXEmbed = false;
- nScreenSaversTimeout_ = 0;
mpInputContext = NULL;
mbInputFocus = False;
@@ -2219,7 +2218,7 @@ void X11SalFrame::StartPresentation( bool bStart )
static CARD16 dpms_suspend_timeout=0;
static CARD16 dpms_off_timeout=0;
- if( bStart || nScreenSaversTimeout_ || DPMSEnabled)
+ if( bStart || DPMSEnabled)
{
if( hPresentationWindow )
{
@@ -2229,12 +2228,6 @@ void X11SalFrame::StartPresentation( bool bStart )
int revert_to = 0;
XGetInputFocus( GetXDisplay(), &hPresFocusWindow, &revert_to );
}
- int timeout, interval, prefer_blanking, allow_exposures;
- XGetScreenSaver( GetXDisplay(),
- &timeout,
- &interval,
- &prefer_blanking,
- &allow_exposures );
// get the DPMS state right before the start
if (DPMSExtensionAvailable)
@@ -2248,16 +2241,6 @@ void X11SalFrame::StartPresentation( bool bStart )
}
if( bStart ) // start show
{
- if ( timeout )
- {
- nScreenSaversTimeout_ = timeout;
- XResetScreenSaver( GetXDisplay() );
- XSetScreenSaver( GetXDisplay(),
- 0,
- interval,
- prefer_blanking,
- allow_exposures );
- }
#if !defined(SOLARIS) && !defined(AIX)
if( DPMSEnabled )
{
@@ -2274,15 +2257,6 @@ void X11SalFrame::StartPresentation( bool bStart )
}
else
{
- if( nScreenSaversTimeout_ )
- {
- XSetScreenSaver( GetXDisplay(),
- nScreenSaversTimeout_,
- interval,
- prefer_blanking,
- allow_exposures );
- nScreenSaversTimeout_ = 0;
- }
#if !defined(SOLARIS) && !defined(AIX)
if ( DPMSEnabled )
{
diff --git a/vcl/unx/generic/window/screensaverinhibitor.cxx b/vcl/unx/generic/window/screensaverinhibitor.cxx
index 0636b06b68fe..4add4bd57848 100644
--- a/vcl/unx/generic/window/screensaverinhibitor.cxx
+++ b/vcl/unx/generic/window/screensaverinhibitor.cxx
@@ -41,6 +41,7 @@ void ScreenSaverInhibitor::inhibit( bool bInhibit, const OUString& sReason,
{
if ( pDisplay != boost::none )
{
+ inhibitXScreenSaver( bInhibit, pDisplay.get() );
inhibitXAutoLock( bInhibit, pDisplay.get() );
}
@@ -168,6 +169,37 @@ void ScreenSaverInhibitor::inhibitGSM( bool bInhibit, const gchar* appname, cons
mnGSMCookie );
}
+/**
+ * Disable screensavers using the XSetScreenSaver/XGetScreenSaver API.
+ *
+ * Worth noting: xscreensaver explicitly ignores this and does it's own
+ * timeout handling.
+ */
+void ScreenSaverInhibitor::inhibitXScreenSaver( bool bInhibit, Display* pDisplay )
+{
+ int nTimeout, nInterval, bPreferBlanking, bAllowExposures;
+ XGetScreenSaver( pDisplay, &nTimeout, &nInterval,
+ &bPreferBlanking, &bAllowExposures );
+
+ // To disable/reenable we simply fiddle the timeout, whilst
+ // retaining all other properties.
+ if ( bInhibit && nTimeout)
+ {
+ mnXScreenSaverTimeout = nTimeout;
+ XResetScreenSaver( pDisplay );
+ XSetScreenSaver( pDisplay, 0, nInterval,
+ bPreferBlanking, bAllowExposures );
+ }
+ else if ( !bInhibit && ( mnXScreenSaverTimeout != boost::none ) )
+ {
+ XSetScreenSaver( pDisplay, mnXScreenSaverTimeout.get(),
+ nInterval, bPreferBlanking,
+ bAllowExposures );
+ mnXScreenSaverTimeout = boost::none;
+ }
+}
+
+
/* definitions from xautolock.c (pl15) */
#define XAUTOLOCK_DISABLE 1
#define XAUTOLOCK_ENABLE 2
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
index 498161e60d24..e2d5507af2b1 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -1118,7 +1118,6 @@ void GtkSalFrame::InitCommon()
m_bSendModChangeOnRelease = false;
m_pIMHandler = NULL;
m_hBackgroundPixmap = None;
- m_nSavedScreenSaverTimeout = 0;
m_nExtStyle = 0;
m_pRegion = NULL;
m_ePointerStyle = static_cast<PointerStyle>(0xffff);
@@ -2553,39 +2552,6 @@ void GtkSalFrame::StartPresentation( bool bStart )
getDisplay()->IsX11Display(),
aWindow,
aDisplay );
-
- if( !getDisplay()->IsX11Display() )
- return;
-
-#if !GTK_CHECK_VERSION(3,0,0)
- Display *pDisplay = GDK_DISPLAY_XDISPLAY( getGdkDisplay() );
-
- int nTimeout, nInterval, bPreferBlanking, bAllowExposures;
- XGetScreenSaver( pDisplay, &nTimeout, &nInterval,
- &bPreferBlanking, &bAllowExposures );
-#endif
- if( bStart )
- {
-#if !GTK_CHECK_VERSION(3,0,0)
- if ( nTimeout )
- {
- m_nSavedScreenSaverTimeout = nTimeout;
- XResetScreenSaver( pDisplay );
- XSetScreenSaver( pDisplay, 0, nInterval,
- bPreferBlanking, bAllowExposures );
- }
-#endif
- }
- else
- {
-#if !GTK_CHECK_VERSION(3,0,0)
- if( m_nSavedScreenSaverTimeout )
- XSetScreenSaver( pDisplay, m_nSavedScreenSaverTimeout,
- nInterval, bPreferBlanking,
- bAllowExposures );
-#endif
- m_nSavedScreenSaverTimeout = 0;
- }
}
void GtkSalFrame::SetAlwaysOnTop( bool bOnTop )