summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/inc/unx/screensaverinhibitor.hxx11
-rw-r--r--vcl/unx/generic/window/salframe.cxx75
-rw-r--r--vcl/unx/generic/window/screensaverinhibitor.cxx41
4 files changed, 59 insertions, 69 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index d485f335e899..575a64fea777 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -734,6 +734,7 @@ $(eval $(call gb_Library_add_libs,vcl,\
-lpthread \
-lGL \
-lX11 \
+ -lXext \
))
$(eval $(call gb_Library_add_exception_objects,vcl,\
diff --git a/vcl/inc/unx/screensaverinhibitor.hxx b/vcl/inc/unx/screensaverinhibitor.hxx
index 8c9ad54f6044..2486961a5dad 100644
--- a/vcl/inc/unx/screensaverinhibitor.hxx
+++ b/vcl/inc/unx/screensaverinhibitor.hxx
@@ -11,6 +11,9 @@
#define INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX
#include <prex.h>
+#if !defined(SOLARIS) && !defined(AIX)
+#include <X11/extensions/dpms.h>
+#endif
#include <postx.h>
#include <rtl/ustring.hxx>
@@ -32,12 +35,20 @@ private:
boost::optional<int> mnXScreenSaverTimeout;
+#if !defined(SOLARIS) && !defined(AIX)
+ BOOL mbDPMSWasEnabled;
+ CARD16 mnDPMSStandbyTimeout;
+ CARD16 mnDPMSSuspendTimeout;
+ CARD16 mnDPMSOffTimeout;
+#endif
+
// 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 );
+ void inhibitDPMS( bool bInhibit, Display* pDisplay );
};
#endif // INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index c1122f7a6919..4be20a723b8b 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -41,9 +41,6 @@
#include <X11/keysym.h>
#include "FWS.hxx"
#include <X11/extensions/shape.h>
-#if !defined(SOLARIS) && !defined(AIX)
-#include <X11/extensions/dpms.h>
-#endif
#include <postx.h>
#include "unx/salunx.h"
@@ -2202,73 +2199,13 @@ void X11SalFrame::StartPresentation( bool bStart )
doReparentPresentationDialogues( GetDisplay() );
hPresentationWindow = (bStart && IsOverrideRedirect() ) ? GetWindow() : None;
- // needs static here to save DPMS settings
- int dummy;
- static bool DPMSExtensionAvailable =
-#if !defined(SOLARIS) && !defined(AIX)
- (DPMSQueryExtension(GetXDisplay(), &dummy, &dummy) != 0);
- static sal_Bool DPMSEnabled = false;
-#else
- false;
- bool DPMSEnabled = false;
- (void)dummy;
-#define CARD16 unsigned short
-#endif
- static CARD16 dpms_standby_timeout=0;
- static CARD16 dpms_suspend_timeout=0;
- static CARD16 dpms_off_timeout=0;
-
- if( bStart || DPMSEnabled)
+ if( bStart && hPresentationWindow )
{
- if( hPresentationWindow )
- {
- /* #i10559# workaround for WindowMaker: try to restore
- * current focus after presentation window is gone
- */
- int revert_to = 0;
- XGetInputFocus( GetXDisplay(), &hPresFocusWindow, &revert_to );
- }
-
- // get the DPMS state right before the start
- if (DPMSExtensionAvailable)
- {
-#if !defined(SOLARIS) && !defined(AIX)
- CARD16 state; // card16 is defined in Xdm.h
- DPMSInfo( GetXDisplay(),
- &state,
- &DPMSEnabled);
-#endif
- }
- if( bStart ) // start show
- {
-#if !defined(SOLARIS) && !defined(AIX)
- if( DPMSEnabled )
- {
- if ( DPMSExtensionAvailable )
- {
- DPMSGetTimeouts( GetXDisplay(),
- &dpms_standby_timeout,
- &dpms_suspend_timeout,
- &dpms_off_timeout);
- DPMSSetTimeouts(GetXDisplay(), 0,0,0);
- }
- }
-#endif
- }
- else
- {
-#if !defined(SOLARIS) && !defined(AIX)
- if ( DPMSEnabled )
- {
- if ( DPMSExtensionAvailable )
- {
- // restore timeouts
- DPMSSetTimeouts(GetXDisplay(), dpms_standby_timeout,
- dpms_suspend_timeout, dpms_off_timeout);
- }
- }
-#endif
- }
+ /* #i10559# workaround for WindowMaker: try to restore
+ * current focus after presentation window is gone
+ */
+ int revert_to = 0;
+ XGetInputFocus( GetXDisplay(), &hPresFocusWindow, &revert_to );
}
}
diff --git a/vcl/unx/generic/window/screensaverinhibitor.cxx b/vcl/unx/generic/window/screensaverinhibitor.cxx
index 4add4bd57848..3b4b1dbfe70c 100644
--- a/vcl/unx/generic/window/screensaverinhibitor.cxx
+++ b/vcl/unx/generic/window/screensaverinhibitor.cxx
@@ -43,6 +43,7 @@ void ScreenSaverInhibitor::inhibit( bool bInhibit, const OUString& sReason,
{
inhibitXScreenSaver( bInhibit, pDisplay.get() );
inhibitXAutoLock( bInhibit, pDisplay.get() );
+ inhibitDPMS( bInhibit, pDisplay.get() );
}
if ( xid != boost::none )
@@ -229,4 +230,44 @@ void ScreenSaverInhibitor::inhibitXAutoLock( bool bInhibit, Display* pDisplay )
sizeof( nMessage ) );
}
+void ScreenSaverInhibitor::inhibitDPMS( bool bInhibit, Display* pDisplay )
+{
+#if !defined(SOLARIS) && !defined(AIX)
+ int dummy;
+ // This won't change while X11 is running, hence
+ // we can evaluate only once and store as static
+ static bool bDPMSExtensionAvailable = ( DPMSQueryExtension( pDisplay, &dummy, &dummy) != 0 );
+
+ if ( !bDPMSExtensionAvailable )
+ {
+ return;
+ }
+
+ if ( bInhibit )
+ {
+ CARD16 state; // unused by us
+ DPMSInfo( pDisplay, &state, &mbDPMSWasEnabled );
+
+ if ( mbDPMSWasEnabled )
+ {
+ DPMSGetTimeouts( pDisplay,
+ &mnDPMSStandbyTimeout,
+ &mnDPMSSuspendTimeout,
+ &mnDPMSOffTimeout );
+ DPMSSetTimeouts( pDisplay,
+ 0,
+ 0,
+ 0 );
+ }
+ }
+ else if ( !bInhibit && mbDPMSWasEnabled )
+ {
+ DPMSSetTimeouts( pDisplay,
+ mnDPMSStandbyTimeout,
+ mnDPMSSuspendTimeout,
+ mnDPMSOffTimeout );
+ }
+#endif // !defined(SOLARIS) && !defined(AIX)
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */