Kaydet (Commit) 189aabbc authored tarafından Andrzej Hunt's avatar Andrzej Hunt

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
üst 5074d1b4
......@@ -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;
......
......@@ -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;
......
......@@ -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 );
};
......
......@@ -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 )
{
......
......@@ -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
......
......@@ -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 )
......
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