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

Add support for org.freedesktop.PowerManagement.Inhibit too

This one seems to be supported by KDE (partially) and XFCE.
On KDE it doesn't inhibit the ScreenSaver, however it's the only
inhibition that appears to be available on XFCE (untested due
to lack of XFCE system at hand).

Change-Id: I4eab04d8ef66fc4fa55f57add46cb1ad15a8e2b3
üst 18817c8c
......@@ -30,7 +30,8 @@ public:
bool bIsX11, const boost::optional<guint> xid, boost::optional<Display*> pDisplay );
private:
boost::optional<guint> mnFDOCookie;
boost::optional<guint> mnFDOCookie; // FDO ScreenSaver Inhibit
boost::optional<guint> mnFDOPMCookie; // FDO PowerManagement Inhibit
boost::optional<guint> mnGSMCookie;
boost::optional<int> mnXScreenSaverTimeout;
......@@ -42,8 +43,20 @@ private:
CARD16 mnDPMSOffTimeout;
#endif
// There are a bunch of different dbus based inhibition APIs. Some call
// themselves ScreenSaver inhibition, some are PowerManagement inhibition,
// but they appear to have the same effect. There doesn't appear to be one
// all encompassing standard, hence we should just try all of tem.
//
// The current APIs we have: (note: the list of supported environments is incomplete)
// FDO: org.freedesktop.ScreenSaver::Inhibit - appears to be supported only by KDE?
// FDOPM: org.freedesktop.PowerManagement.Inhibit::Inhibit - XFCE, (KDE) ?
// (KDE: doesn't inhibit screensaver, but does inhibit PowerManagement)
// GSM: org.gnome.SessionManager::Inhibit - gnome 3
//
// Note: the Uninhibit call has different spelling in FDO (UnInhibit) vs GSM (Uninhibit)
void inhibitFDO( bool bInhibit, const gchar* appname, const gchar* reason );
void inhibitFDOPM( 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 );
......
......@@ -22,6 +22,10 @@
#define FDO_DBUS_PATH "/org/freedesktop/ScreenSaver"
#define FDO_DBUS_INTERFACE "org.freedesktop.ScreenSaver"
#define FDOPM_DBUS_SERVICE "org.freedesktop.PowerManagement.Inhibit"
#define FDOPM_DBUS_PATH "/org/freedesktop/PowerManagement/Inhibit"
#define FDOPM_DBUS_INTERFACE "org.freedesktop.PowerManagement.Inhibit"
#define GSM_DBUS_SERVICE "org.gnome.SessionManager"
#define GSM_DBUS_PATH "/org/gnome/SessionManager"
#define GSM_DBUS_INTERFACE "org.gnome.SessionManager"
......@@ -36,6 +40,7 @@ void ScreenSaverInhibitor::inhibit( bool bInhibit, const OUString& sReason,
const OString aReason = OUStringToOString( sReason, RTL_TEXTENCODING_UTF8 );
inhibitFDO( bInhibit, appname, aReason.getStr() );
inhibitFDOPM( bInhibit, appname, aReason.getStr() );
if ( bIsX11 )
{
......@@ -145,6 +150,29 @@ void ScreenSaverInhibitor::inhibitFDO( bool bInhibit, const gchar* appname, cons
mnFDOCookie );
}
void ScreenSaverInhibitor::inhibitFDOPM( bool bInhibit, const gchar* appname, const gchar* reason )
{
dbusInhibit( bInhibit,
FDOPM_DBUS_SERVICE, FDOPM_DBUS_PATH, FDOPM_DBUS_INTERFACE,
[appname, reason] ( DBusGProxy *proxy, guint& nCookie, GError*& error ) -> bool {
return dbus_g_proxy_call( proxy,
"Inhibit", &error,
G_TYPE_STRING, appname,
G_TYPE_STRING, reason,
G_TYPE_INVALID,
G_TYPE_UINT, &nCookie,
G_TYPE_INVALID );
},
[] ( DBusGProxy *proxy, const guint nCookie, GError*& error ) -> bool {
return dbus_g_proxy_call( proxy,
"UnInhibit", &error,
G_TYPE_UINT, nCookie,
G_TYPE_INVALID,
G_TYPE_INVALID );
},
mnFDOPMCookie );
}
void ScreenSaverInhibitor::inhibitGSM( bool bInhibit, const gchar* appname, const gchar* reason, const guint xid )
{
dbusInhibit( bInhibit,
......
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