[notification-daemon] Fix the screensaver lock detection
- From: William Jon McCann <mccann src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [notification-daemon] Fix the screensaver lock detection
- Date: Sat, 9 Jan 2010 00:55:18 +0000 (UTC)
commit 5df44918e69fd66044adaac6a325e01d9f89d210
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jan 8 19:39:41 2010 -0500
Fix the screensaver lock detection
Check gnome-screensaver to see if the screen is locked.
src/daemon/daemon.c | 59 +++++++++++++++++++++++++++-----------------------
1 files changed, 32 insertions(+), 27 deletions(-)
---
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 7b5bffd..6c16cd5 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -874,33 +874,38 @@ url_clicked_cb(GtkWindow *nw, const char *url)
static gboolean
screensaver_active(GtkWidget *nw)
{
- GdkDisplay *display = gdk_drawable_get_display(GDK_DRAWABLE(nw->window));
- Atom type;
- int format;
- unsigned long nitems, bytes_after;
- unsigned char *temp_data;
- gboolean active = FALSE;
- Atom XA_BLANK = gdk_x11_get_xatom_by_name_for_display(display, "BLANK");
- Atom XA_LOCK = gdk_x11_get_xatom_by_name_for_display(display, "LOCK");
-
- /* Check for a screensaver first. */
- if (XGetWindowProperty(
- GDK_DISPLAY_XDISPLAY(display),
- GDK_ROOT_WINDOW(),
- gdk_x11_get_xatom_by_name_for_display(display, "_SCREENSAVER_STATUS"),
- 0, G_MAXLONG, False, XA_INTEGER, &type, &format, &nitems,
- &bytes_after, &temp_data) == Success &&
- type && temp_data != NULL)
+ DBusGConnection *connection;
+ DBusGProxy *gs_proxy;
+ GError *error;
+ gboolean active;
+
+ active = FALSE;
+
+ error = NULL;
+ connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+ if (connection == NULL)
{
- CARD32 *data = (CARD32 *)temp_data;
+ g_warning ("Failed to get dbus connection: %s", error->message);
+ g_error_free(error);
+ goto out;
- active = (type == XA_INTEGER && nitems >= 3 &&
- (time_t)data[1] > (time_t)666000000L &&
- (data[0] == XA_BLANK || data[0] == XA_LOCK));
}
+ gs_proxy = dbus_g_proxy_new_for_name(connection,
+ "org.gnome.ScreenSaver",
+ "/",
+ "org.gnome.ScreenSaver");
+
+ if (!dbus_g_proxy_call(gs_proxy, "GetActive", &error,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &active,
+ G_TYPE_INVALID))
+ {
+ g_warning("Failed to call gnome-screensaver: %s", error->message);
+ g_error_free(error);
+ }
+ g_object_unref (gs_proxy);
+out:
- if (temp_data != NULL)
- XFree(temp_data);
return active;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]