Kaydet (Commit) 18817c8c authored tarafından Andrzej Hunt's avatar Andrzej Hunt

Move DPMS inhibition to ScreenSaverInhibitor

We should also be doing this irregardless of vcl backend

Change-Id: I46ec2c654dfd9ab3c6bcf6da19e7ffa2c05890b9
üst 189aabbc
......@@ -734,6 +734,7 @@ $(eval $(call gb_Library_add_libs,vcl,\
-lpthread \
-lGL \
-lX11 \
-lXext \
))
$(eval $(call gb_Library_add_exception_objects,vcl,\
......
......@@ -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
......
......@@ -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 );
}
}
......
......@@ -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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment