summaryrefslogtreecommitdiff
path: root/xfce4-session/xfsm-consolekit.c
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2016-05-31 11:39:01 +0300
committerEric Koegel <eric.koegel@gmail.com>2016-05-31 11:40:30 +0300
commit9fa8c63b4377bcb46b8471da509ff8bd909c4bf0 (patch)
treeb3779562196ffaefc29060e53f0d5ffb7e7b1c7b /xfce4-session/xfsm-consolekit.c
parent34f86835e7c1cbe4d5d4d27a0659622ac1001d8c (diff)
downloadxfce4-session-9fa8c63b4377bcb46b8471da509ff8bd909c4bf0.tar.gz
Handle screensaver with it's own object (Bug #12603)
Move the screensaver inhibit, heartbeat, and lock code to its own set of files we can easily share with xfce4-power-manager. Use the screensaver's dbus API if it supports it for inhibit and lock calls. Otherwise, use the heartbeat-command and LockCommand from xfpm and xfsm if available. Finally, for the lock function, fallback to trying xdg-screensaver, xflock4, and xscreensaver-command in that order.
Diffstat (limited to 'xfce4-session/xfsm-consolekit.c')
-rw-r--r--xfce4-session/xfsm-consolekit.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/xfce4-session/xfsm-consolekit.c b/xfce4-session/xfsm-consolekit.c
index d1dd73aa..33a995fb 100644
--- a/xfce4-session/xfsm-consolekit.c
+++ b/xfce4-session/xfsm-consolekit.c
@@ -23,6 +23,7 @@
#include <gio/gio.h>
#include <xfce4-session/xfsm-consolekit.h>
+#include <xfce4-session/xfce-screensaver.h>
#include <libxfsm/xfsm-util.h>
#include "xfsm-global.h"
@@ -48,6 +49,7 @@ struct _XfsmConsolekit
GDBusProxy *proxy;
guint name_id;
+ XfceScreenSaver *screensaver;
};
@@ -128,6 +130,8 @@ xfsm_consolekit_init (XfsmConsolekit *consolekit)
name_lost,
consolekit,
NULL);
+
+ consolekit->screensaver = xfce_screensaver_new ();
}
@@ -150,6 +154,8 @@ xfsm_consolekit_proxy_free (XfsmConsolekit *consolekit)
g_object_unref (G_OBJECT (consolekit->proxy));
consolekit->proxy = NULL;
}
+
+ g_object_unref (G_OBJECT (consolekit->screensaver));
}
@@ -378,14 +384,15 @@ xfsm_consolekit_can_shutdown (XfsmConsolekit *consolekit,
static gboolean
-lock_screen (GError **error)
+lock_screen (XfsmConsolekit *consolekit,
+ GError **error)
{
XfconfChannel *channel;
gboolean ret = TRUE;
channel = xfsm_open_config ();
if (xfconf_channel_get_bool (channel, "/shutdown/LockScreen", FALSE))
- ret = g_spawn_command_line_async ("xflock4", error);
+ ret = xfce_screensaver_lock (consolekit->screensaver);
return ret;
}
@@ -409,7 +416,7 @@ xfsm_consolekit_try_suspend (XfsmConsolekit *consolekit,
return FALSE;
}
- if (!lock_screen (error))
+ if (!lock_screen (consolekit, error))
return FALSE;
return xfsm_consolekit_try_sleep (consolekit, "Suspend", error);
@@ -436,7 +443,7 @@ xfsm_consolekit_try_hibernate (XfsmConsolekit *consolekit,
return FALSE;
}
- if (!lock_screen (error))
+ if (!lock_screen (consolekit, error))
return FALSE;
return xfsm_consolekit_try_sleep (consolekit, "Hibernate", error);