[Xfce4-commits] [apps/xfce4-screensaver] 01/01: Use X11 idle timer and ScreenSaver events instead of GNOME session presence
noreply at xfce.org
noreply at xfce.org
Fri Nov 9 03:23:46 CET 2018
This is an automated email from the git hooks/post-receive script.
b l u e s a b r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-screensaver.
commit 160aad2f539a6bcce8a7fc729a1955b1abefbae9
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Thu Nov 8 21:23:36 2018 -0500
Use X11 idle timer and ScreenSaver events instead of GNOME session presence
---
src/Makefile.am | 20 +-
src/gs-listener-x11.c | 272 ++++++++++++++++++++
src/gs-listener-x11.h | 60 +++++
src/gs-monitor.c | 186 ++------------
src/gs-watcher-x11.c | 676 --------------------------------------------------
src/gs-watcher.h | 67 -----
src/test-watcher.c | 106 --------
7 files changed, 357 insertions(+), 1030 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 208d0f2..9dd9516 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -48,7 +48,6 @@ libexec_PROGRAMS = \
noinst_PROGRAMS = \
test-fade \
test-passwd \
- test-watcher \
test-window \
$(NULL)
@@ -100,21 +99,6 @@ test_passwd_LDADD = \
$(AUTH_LIBS) \
$(NULL)
-test_watcher_SOURCES = \
- test-watcher.c \
- gs-watcher.h \
- gs-watcher-x11.c \
- gs-marshal.c \
- gs-marshal.h \
- gs-debug.c \
- gs-debug.h \
- $(NULL)
-
-test_watcher_LDADD = \
- $(XFCE_SCREENSAVER_LIBS) \
- $(SAVER_LIBS) \
- $(NULL)
-
test_window_SOURCES = \
test-window.c \
gs-window.h \
@@ -209,10 +193,10 @@ xfce4_screensaver_SOURCES = \
xfce4-screensaver.h \
gs-monitor.c \
gs-monitor.h \
- gs-watcher-x11.c \
- gs-watcher.h \
gs-listener-dbus.c \
gs-listener-dbus.h \
+ gs-listener-x11.c \
+ gs-listener-x11.h \
gs-manager.c \
gs-manager.h \
gs-window-x11.c \
diff --git a/src/gs-listener-x11.c b/src/gs-listener-x11.c
new file mode 100644
index 0000000..630e109
--- /dev/null
+++ b/src/gs-listener-x11.c
@@ -0,0 +1,272 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Authors: William Jon McCann <mccann at jhu.edu>
+ *
+ */
+
+#include "config.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3, 0, 0)
+#include <gtk/gtkx.h>
+#else
+#include <gdk/gdkx.h>
+#endif
+
+#ifdef HAVE_MIT_SAVER_EXTENSION
+#include <X11/extensions/scrnsaver.h>
+#endif
+
+#include "gs-listener-x11.h"
+#include "gs-marshal.h"
+#include "gs-debug.h"
+
+static void gs_listener_x11_class_init (GSListenerX11Class *klass);
+static void gs_listener_x11_init (GSListenerX11 *listener);
+static void gs_listener_x11_finalize (GObject *object);
+
+#define GS_LISTENER_X11_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GS_TYPE_LISTENER_X11, GSListenerX11Private))
+
+struct GSListenerX11Private
+{
+#ifdef HAVE_MIT_SAVER_EXTENSION
+ int scrnsaver_event_base;
+#endif
+
+ gint lock_timeout;
+ guint lock_timer_id;
+};
+
+enum {
+ LOCK,
+ LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0, };
+
+G_DEFINE_TYPE (GSListenerX11, gs_listener_x11, G_TYPE_OBJECT)
+
+static void
+gs_listener_x11_class_init (GSListenerX11Class *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gs_listener_x11_finalize;
+
+ signals [LOCK] =
+ g_signal_new ("lock",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GSListenerX11Class, lock),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ g_type_class_add_private (klass, sizeof (GSListenerX11Private));
+}
+
+static gboolean
+lock_timer (GSListenerX11 *listener)
+{
+ Display *display = gdk_x11_display_get_xdisplay(gdk_display_get_default());
+ static XScreenSaverInfo *mit_info = NULL;
+ guint idle_time;
+
+ mit_info = XScreenSaverAllocInfo();
+ XScreenSaverQueryInfo(display, GDK_ROOT_WINDOW(), mit_info);
+ idle_time = mit_info->idle / 1000; // seconds
+
+ if (idle_time >= listener->priv->lock_timeout)
+ {
+ listener->priv->lock_timer_id = 0;
+
+ gs_debug("Lock timer");
+
+ g_signal_emit(listener, signals[LOCK], 0);
+ }
+ else
+ {
+ gs_debug("Idle time interrupted. Resetting lock timer for %i seconds", listener->priv->lock_timeout - idle_time);
+
+ listener->priv->lock_timer_id = g_timeout_add_seconds(listener->priv->lock_timeout - idle_time,
+ (GSourceFunc)lock_timer,
+ listener);
+ }
+
+ return FALSE;
+}
+
+static void
+remove_lock_timer (GSListenerX11 *listener)
+{
+ if (listener->priv->lock_timer_id != 0) {
+ g_source_remove (listener->priv->lock_timer_id);
+ listener->priv->lock_timer_id = 0;
+ }
+}
+
+static void
+reset_lock_timer (GSListenerX11 *listener)
+{
+ remove_lock_timer (listener);
+
+ listener->priv->lock_timer_id = g_timeout_add_seconds(listener->priv->lock_timeout,
+ (GSourceFunc)lock_timer,
+ listener);
+}
+
+static GdkFilterReturn
+xroot_filter (GdkXEvent *xevent,
+ GdkEvent *event,
+ gpointer data)
+{
+ GSListenerX11 *listener;
+ XEvent *ev;
+
+ g_return_val_if_fail (data != NULL, GDK_FILTER_CONTINUE);
+ g_return_val_if_fail (GS_IS_LISTENER_X11 (data), GDK_FILTER_CONTINUE);
+
+ listener = GS_LISTENER_X11 (data);
+
+ ev = xevent;
+
+ switch (ev->xany.type) {
+ default:
+ /* extension events */
+#ifdef HAVE_MIT_SAVER_EXTENSION
+ if (ev->xany.type == (listener->priv->scrnsaver_event_base + ScreenSaverNotify)) {
+ XScreenSaverNotifyEvent *xssne = (XScreenSaverNotifyEvent *) ev;
+ switch (xssne->state) {
+ case ScreenSaverOff:
+ // Reset the lock timer
+ gs_debug("ScreenSaver timer reset");
+ reset_lock_timer (listener);
+ break;
+
+ case ScreenSaverDisabled:
+ // Disable the lock timer
+ gs_debug ("ScreenSaver timer disabled");
+ remove_lock_timer (listener);
+ break;
+
+ case ScreenSaverOn:
+ // lock now!
+ gs_debug("ScreenSaver on");
+ g_signal_emit (listener, signals [LOCK], 0);
+ break;
+
+ }
+ }
+#endif
+ break;
+ }
+
+ return GDK_FILTER_CONTINUE;
+}
+
+
+gboolean
+gs_listener_x11_acquire (GSListenerX11 *listener)
+{
+ GdkDisplay *display;
+ GdkScreen *screen;
+ GdkWindow *window;
+#ifdef HAVE_MIT_SAVER_EXTENSION
+ int scrnsaver_error_base;
+ unsigned long events;
+#endif
+
+ g_return_val_if_fail (listener != NULL, FALSE);
+
+ display = gdk_display_get_default ();
+ screen = gdk_display_get_default_screen (display);
+ window = gdk_screen_get_root_window (screen);
+
+#ifdef HAVE_MIT_SAVER_EXTENSION
+ gdk_error_trap_push ();
+ if (XScreenSaverQueryExtension (GDK_DISPLAY_XDISPLAY (display), &listener->priv->scrnsaver_event_base, &scrnsaver_error_base)) {
+ events = ScreenSaverNotifyMask;
+ XScreenSaverSelectInput (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), events);
+ gs_debug ("ScreenSaver Registered");
+ } else {
+ gs_debug ("ScreenSaverExtension not found");
+ }
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gdk_error_trap_pop_ignored ();
+#else
+ gdk_error_trap_pop ();
+#endif
+#endif
+
+ gdk_window_add_filter (NULL, (GdkFilterFunc)xroot_filter, listener);
+
+ return TRUE;
+}
+
+void
+gs_listener_x11_set_lock_after (GSListenerX11 *listener,
+ gint lock_after)
+{
+ listener->priv->lock_timeout = lock_after * 60;
+ reset_lock_timer(listener);
+}
+
+static void
+gs_listener_x11_init (GSListenerX11 *listener)
+{
+ listener->priv = GS_LISTENER_X11_GET_PRIVATE (listener);
+
+ listener->priv->lock_timeout = 300;
+}
+
+static void
+gs_listener_x11_finalize (GObject *object)
+{
+ GSListenerX11 *listener;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_LISTENER_X11 (object));
+
+ listener = GS_LISTENER_X11 (object);
+
+ g_return_if_fail (listener->priv != NULL);
+
+ gdk_window_remove_filter (NULL, (GdkFilterFunc)xroot_filter, NULL);
+
+ G_OBJECT_CLASS (gs_listener_x11_parent_class)->finalize (object);
+}
+
+GSListenerX11 *
+gs_listener_x11_new (void)
+{
+ GSListenerX11 *listener;
+
+ listener = g_object_new (GS_TYPE_LISTENER_X11, NULL);
+
+ return GS_LISTENER_X11 (listener);
+}
diff --git a/src/gs-listener-x11.h b/src/gs-listener-x11.h
new file mode 100644
index 0000000..5ba2e39
--- /dev/null
+++ b/src/gs-listener-x11.h
@@ -0,0 +1,60 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Authors: William Jon McCann <mccann at jhu.edu>
+ *
+ */
+
+#ifndef __GS_LISTENER_X11_H
+#define __GS_LISTENER_X11_H
+
+G_BEGIN_DECLS
+
+#define GS_TYPE_LISTENER_X11 (gs_listener_x11_get_type ())
+#define GS_LISTENER_X11(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GS_TYPE_LISTENER_X11, GSListenerX11))
+#define GS_LISTENER_X11_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GS_TYPE_LISTENER_X11, GSListenerX11Class))
+#define GS_IS_LISTENER_X11(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GS_TYPE_LISTENER_X11))
+#define GS_IS_LISTENER_X11_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GS_TYPE_LISTENER_X11))
+#define GS_LISTENER_X11_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GS_TYPE_LISTENER_X11, GSListenerX11Class))
+
+typedef struct GSListenerX11Private GSListenerX11Private;
+
+typedef struct
+{
+ GObject parent;
+ GSListenerX11Private *priv;
+} GSListenerX11;
+
+typedef struct
+{
+ GObjectClass parent_class;
+
+ void (* lock) (GSListenerX11 *listener);
+
+} GSListenerX11Class;
+
+GType gs_listener_x11_get_type (void);
+
+GSListenerX11 *gs_listener_x11_new (void);
+gboolean gs_listener_x11_acquire (GSListenerX11 *listener);
+void gs_listener_x11_set_lock_after (GSListenerX11 *listener,
+ gint lock_after);
+
+G_END_DECLS
+
+#endif /* __GS_LISTENER_X11_H */
diff --git a/src/gs-monitor.c b/src/gs-monitor.c
index f71d4ec..0a2048a 100644
--- a/src/gs-monitor.c
+++ b/src/gs-monitor.c
@@ -35,11 +35,11 @@
#include "xfce4-screensaver.h"
#include "gs-manager.h"
-#include "gs-watcher.h"
#include "gs-fade.h"
#include "gs-grab.h"
#include "gs-listener-dbus.h"
+#include "gs-listener-x11.h"
#include "gs-monitor.h"
#include "gs-prefs.h"
#include "gs-debug.h"
@@ -49,8 +49,8 @@ static void gs_monitor_init(GSMonitor* monitor);
static void gs_monitor_finalize(GObject* object);
struct GSMonitorPrivate {
- GSWatcher* watcher;
GSListener* listener;
+ GSListenerX11 *listener_x11;
GSManager* manager;
GSPrefs* prefs;
GSFade* fade;
@@ -79,93 +79,6 @@ static void manager_deactivated_cb(GSManager* manager, GSMonitor* monitor)
gs_listener_set_active (monitor->priv->listener, FALSE);
}
-static gboolean watcher_idle_cb(GSWatcher* watcher, gboolean is_idle, GSMonitor* monitor)
-{
- gboolean res;
-
- gs_debug ("Idle signal detected: %d", is_idle);
-
- res = gs_listener_set_session_idle(monitor->priv->listener, is_idle);
-
- return res;
-}
-
-static gboolean release_grab_timeout(GSMonitor* monitor)
-{
- gboolean manager_active;
-
- manager_active = gs_manager_get_active(monitor->priv->manager);
-
- if (! manager_active)
- {
- gs_grab_release(monitor->priv->grab, TRUE);
- }
-
- monitor->priv->release_grab_id = 0;
- return FALSE;
-}
-
-static gboolean watcher_idle_notice_cb(GSWatcher* watcher, gboolean in_effect, GSMonitor* monitor)
-{
- gboolean activation_enabled;
- gboolean inhibited;
- gboolean handled;
-
- gs_debug("Idle notice signal detected: %d", in_effect);
-
- /* only fade if screensaver can activate */
- activation_enabled = gs_listener_get_activation_enabled(monitor->priv->listener);
- inhibited = gs_listener_is_inhibited(monitor->priv->listener);
-
- handled = FALSE;
-
- if (in_effect)
- {
- if (activation_enabled && ! inhibited)
- {
- /* start slow fade */
- if (gs_grab_grab_offscreen(monitor->priv->grab, FALSE, FALSE))
- {
- gs_fade_async(monitor->priv->fade, FADE_TIMEOUT, NULL, NULL);
- }
- else
- {
- gs_debug("Could not grab the keyboard so not performing idle warning fade-out");
- }
-
- handled = TRUE;
- }
- }
- else
- {
- gboolean manager_active;
-
- manager_active = gs_manager_get_active(monitor->priv->manager);
- /* cancel the fade unless manager was activated */
- if (! manager_active)
- {
- gs_debug("manager not active, performing fade cancellation");
- gs_fade_reset(monitor->priv->fade);
-
- /* don't release the grab immediately to prevent typing passwords into windows */
- if (monitor->priv->release_grab_id != 0)
- {
- g_source_remove(monitor->priv->release_grab_id);
- }
-
- monitor->priv->release_grab_id = g_timeout_add(1000, (GSourceFunc) release_grab_timeout, monitor);
- }
- else
- {
- gs_debug("manager active, skipping fade cancellation");
- }
-
- handled = TRUE;
- }
-
- return handled;
-}
-
static void gs_monitor_lock_screen(GSMonitor* monitor)
{
gboolean res;
@@ -213,7 +126,18 @@ static void listener_lock_cb(GSListener* listener, GSMonitor* monitor)
{
gs_debug("Locking disabled by the administrator");
}
+}
+static void listener_x11_lock_cb(GSListenerX11* listener, GSMonitor* monitor)
+{
+ if (monitor->priv->prefs->lock_enabled)
+ {
+ gs_monitor_lock_screen(monitor);
+ }
+ else
+ {
+ gs_debug("Locking disabled by the administrator");
+ }
}
static void listener_quit_cb(GSListener* listener, GSMonitor* monitor)
@@ -236,7 +160,6 @@ static gboolean listener_active_changed_cb(GSListener* listener, gboolean active
{
gboolean res;
gboolean ret;
- gboolean idle_watch_enabled;
res = gs_manager_set_active(monitor->priv->manager, active);
@@ -251,18 +174,6 @@ static gboolean listener_active_changed_cb(GSListener* listener, gboolean active
done:
- idle_watch_enabled = gs_watcher_get_enabled(monitor->priv->watcher);
-
- if (ret && idle_watch_enabled)
- {
- res = gs_watcher_set_active(monitor->priv->watcher, !active);
-
- if (!res)
- {
- gs_debug("Unable to set the idle watcher active: %d", !active);
- }
- }
-
return ret;
}
@@ -278,10 +189,6 @@ static void listener_simulate_user_activity_cb(GSListener* listener, GSMonitor*
static void _gs_monitor_update_from_prefs(GSMonitor* monitor, GSPrefs* prefs)
{
- gboolean idle_detection_enabled;
- gboolean idle_detection_active;
- gboolean activate_watch;
- gboolean manager_active;
gboolean lock_enabled;
gboolean user_switch_enabled;
@@ -302,36 +209,6 @@ static void _gs_monitor_update_from_prefs(GSMonitor* monitor, GSPrefs* prefs)
/* enable activation when allowed */
gs_listener_set_activation_enabled(monitor->priv->listener, monitor->priv->prefs->idle_activation_enabled);
-
- /* idle detection always enabled */
- idle_detection_enabled = TRUE;
-
- gs_watcher_set_enabled(monitor->priv->watcher, idle_detection_enabled);
-
- /* in the case where idle detection is reenabled we may need to
- activate the watcher too */
-
- manager_active = gs_manager_get_active(monitor->priv->manager);
- idle_detection_active = gs_watcher_get_active(monitor->priv->watcher);
-
- activate_watch = (! manager_active && ! idle_detection_active && idle_detection_enabled);
-
- if (activate_watch)
- {
- gs_watcher_set_active(monitor->priv->watcher, TRUE);
- }
-
- if (monitor->priv->prefs->status_message_enabled)
- {
- char* text;
- g_object_get(monitor->priv->watcher, "status-message", &text, NULL);
- gs_manager_set_status_message(monitor->priv->manager, text);
- g_free(text);
- }
- else
- {
- gs_manager_set_status_message(monitor->priv->manager, NULL);
- }
}
static void disconnect_listener_signals(GSMonitor* monitor)
@@ -343,6 +220,8 @@ static void disconnect_listener_signals(GSMonitor* monitor)
g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_throttle_changed_cb, monitor);
g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_simulate_user_activity_cb, monitor);
g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_show_message_cb, monitor);
+
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener_x11, listener_x11_lock_cb, monitor);
}
static void connect_listener_signals(GSMonitor* monitor)
@@ -354,29 +233,9 @@ static void connect_listener_signals(GSMonitor* monitor)
g_signal_connect(monitor->priv->listener, "throttle-changed", G_CALLBACK(listener_throttle_changed_cb), monitor);
g_signal_connect(monitor->priv->listener, "simulate-user-activity", G_CALLBACK(listener_simulate_user_activity_cb), monitor);
g_signal_connect(monitor->priv->listener, "show-message", G_CALLBACK(listener_show_message_cb), monitor);
-}
-
-static void on_watcher_status_message_changed(GSWatcher* watcher, GParamSpec* pspec, GSMonitor* monitor)
-{
- char* text;
- g_object_get(watcher, "status-message", &text, NULL);
- gs_manager_set_status_message(monitor->priv->manager, text);
- g_free(text);
-}
-
-static void disconnect_watcher_signals(GSMonitor *monitor)
-{
- g_signal_handlers_disconnect_by_func(monitor->priv->watcher, watcher_idle_cb, monitor);
- g_signal_handlers_disconnect_by_func(monitor->priv->watcher, watcher_idle_notice_cb, monitor);
- g_signal_handlers_disconnect_by_func(monitor->priv->watcher, on_watcher_status_message_changed, monitor);
-}
-
-static void connect_watcher_signals(GSMonitor *monitor)
-{
- g_signal_connect(monitor->priv->watcher, "idle-changed", G_CALLBACK(watcher_idle_cb), monitor);
- g_signal_connect(monitor->priv->watcher, "idle-notice-changed", G_CALLBACK(watcher_idle_notice_cb), monitor);
- g_signal_connect(monitor->priv->watcher, "notify::status-message", G_CALLBACK(on_watcher_status_message_changed), monitor);
+ g_signal_connect(monitor->priv->listener_x11, "lock",
+ G_CALLBACK(listener_x11_lock_cb), monitor);
}
static void disconnect_manager_signals(GSMonitor* monitor)
@@ -410,14 +269,12 @@ static void gs_monitor_init(GSMonitor* monitor)
connect_prefs_signals(monitor);
monitor->priv->listener = gs_listener_new();
+ monitor->priv->listener_x11 = gs_listener_x11_new();
connect_listener_signals(monitor);
monitor->priv->fade = gs_fade_new();
monitor->priv->grab = gs_grab_new();
- monitor->priv->watcher = gs_watcher_new();
- connect_watcher_signals(monitor);
-
monitor->priv->manager = gs_manager_new();
connect_manager_signals(monitor);
@@ -435,15 +292,14 @@ static void gs_monitor_finalize(GObject* object)
g_return_if_fail(monitor->priv != NULL);
- disconnect_watcher_signals(monitor);
disconnect_listener_signals(monitor);
disconnect_manager_signals(monitor);
disconnect_prefs_signals(monitor);
g_object_unref(monitor->priv->fade);
g_object_unref(monitor->priv->grab);
- g_object_unref(monitor->priv->watcher);
g_object_unref(monitor->priv->listener);
+ g_object_unref(monitor->priv->listener_x11);
g_object_unref(monitor->priv->manager);
g_object_unref(monitor->priv->prefs);
@@ -456,6 +312,8 @@ GSMonitor* gs_monitor_new(void)
monitor = g_object_new(GS_TYPE_MONITOR, NULL);
+ gs_listener_x11_set_lock_after(monitor->priv->listener_x11, 1);
+
return GS_MONITOR(monitor);
}
@@ -468,5 +326,7 @@ gboolean gs_monitor_start(GSMonitor* monitor, GError** error)
return FALSE;
}
+ gs_listener_x11_acquire(monitor->priv->listener_x11);
+
return TRUE;
}
diff --git a/src/gs-watcher-x11.c b/src/gs-watcher-x11.c
deleted file mode 100644
index fc36b84..0000000
--- a/src/gs-watcher-x11.c
+++ /dev/null
@@ -1,676 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * Copyright (C) 2004-2006 William Jon McCann <mccann at jhu.edu>
- * Copyright (C) 2008 Red Hat, Inc.
- * Copyright (C) 2018 Sean Davis <bluesabre at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Authors: William Jon McCann <mccann at jhu.edu>
- *
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <errno.h>
-
-#include <string.h>
-#include <gdk/gdkx.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-
-#include "gs-watcher.h"
-#include "gs-marshal.h"
-#include "gs-debug.h"
-
-static void gs_watcher_class_init (GSWatcherClass *klass);
-static void gs_watcher_init (GSWatcher *watcher);
-static void gs_watcher_finalize (GObject *object);
-
-static gboolean watchdog_timer (GSWatcher *watcher);
-
-struct GSWatcherPrivate
-{
- /* settings */
- guint enabled : 1;
- guint delta_notice_timeout;
-
- /* state */
- guint active : 1;
- guint idle : 1;
- guint idle_notice : 1;
-
- guint idle_id;
- char *status_message;
-
- DBusGProxy *presence_proxy;
- guint watchdog_timer_id;
-};
-
-enum
-{
- PROP_0,
- PROP_STATUS_MESSAGE
-};
-
-enum
-{
- IDLE_CHANGED,
- IDLE_NOTICE_CHANGED,
- LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0, };
-
-G_DEFINE_TYPE_WITH_PRIVATE (GSWatcher, gs_watcher, G_TYPE_OBJECT)
-
-static void
-remove_watchdog_timer (GSWatcher *watcher)
-{
- if (watcher->priv->watchdog_timer_id != 0)
- {
- g_source_remove (watcher->priv->watchdog_timer_id);
- watcher->priv->watchdog_timer_id = 0;
- }
-}
-
-static void
-add_watchdog_timer (GSWatcher *watcher,
- glong timeout)
-{
- watcher->priv->watchdog_timer_id = g_timeout_add (timeout,
- (GSourceFunc)watchdog_timer,
- watcher);
-}
-
-static void
-gs_watcher_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GSWatcher *self;
-
- self = GS_WATCHER (object);
-
- switch (prop_id)
- {
- case PROP_STATUS_MESSAGE:
- g_value_set_string (value, self->priv->status_message);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-set_status_text (GSWatcher *watcher,
- const char *text)
-{
- g_free (watcher->priv->status_message);
-
- watcher->priv->status_message = g_strdup (text);
- g_object_notify (G_OBJECT (watcher), "status-message");
-}
-
-static void
-gs_watcher_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GSWatcher *self;
-
- self = GS_WATCHER (object);
-
- switch (prop_id)
- {
- case PROP_STATUS_MESSAGE:
- set_status_text (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gs_watcher_class_init (GSWatcherClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = gs_watcher_finalize;
- object_class->get_property = gs_watcher_get_property;
- object_class->set_property = gs_watcher_set_property;
-
- g_object_class_install_property (object_class,
- PROP_STATUS_MESSAGE,
- g_param_spec_string ("status-message",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
-
- signals [IDLE_CHANGED] =
- g_signal_new ("idle-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSWatcherClass, idle_changed),
- NULL,
- NULL,
- gs_marshal_BOOLEAN__BOOLEAN,
- G_TYPE_BOOLEAN,
- 1, G_TYPE_BOOLEAN);
- signals [IDLE_NOTICE_CHANGED] =
- g_signal_new ("idle-notice-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSWatcherClass, idle_notice_changed),
- NULL,
- NULL,
- gs_marshal_BOOLEAN__BOOLEAN,
- G_TYPE_BOOLEAN,
- 1, G_TYPE_BOOLEAN);
-}
-
-static gboolean
-_gs_watcher_set_session_idle_notice (GSWatcher *watcher,
- gboolean in_effect)
-{
- gboolean res;
-
- res = FALSE;
-
- if (in_effect != watcher->priv->idle_notice)
- {
- g_signal_emit (watcher, signals [IDLE_NOTICE_CHANGED], 0, in_effect, &res);
- if (res)
- {
- gs_debug ("Changing idle notice state: %d", in_effect);
-
- watcher->priv->idle_notice = in_effect;
- }
- else
- {
- gs_debug ("Idle notice signal not handled: %d", in_effect);
- }
- }
-
- return res;
-}
-
-static gboolean
-_gs_watcher_set_session_idle (GSWatcher *watcher,
- gboolean is_idle)
-{
- gboolean res;
-
- res = FALSE;
-
- if (is_idle != watcher->priv->idle)
- {
- g_signal_emit (watcher, signals [IDLE_CHANGED], 0, is_idle, &res);
- if (res)
- {
- gs_debug ("Changing idle state: %d", is_idle);
-
- watcher->priv->idle = is_idle;
- }
- else
- {
- gs_debug ("Idle changed signal not handled: %d", is_idle);
- }
- }
-
- return res;
-}
-
-gboolean
-gs_watcher_get_active (GSWatcher *watcher)
-{
- gboolean active;
-
- g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
-
- active = watcher->priv->active;
-
- return active;
-}
-
-static void
-_gs_watcher_reset_state (GSWatcher *watcher)
-{
- watcher->priv->idle = FALSE;
- watcher->priv->idle_notice = FALSE;
-}
-
-static gboolean
-_gs_watcher_set_active_internal (GSWatcher *watcher,
- gboolean active)
-{
- if (active != watcher->priv->active)
- {
- /* reset state */
- _gs_watcher_reset_state (watcher);
-
- watcher->priv->active = active;
- }
-
- return TRUE;
-}
-
-gboolean
-gs_watcher_set_active (GSWatcher *watcher,
- gboolean active)
-{
- g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
-
- gs_debug ("turning watcher: %s", active ? "ON" : "OFF");
-
- if (watcher->priv->active == active)
- {
- gs_debug ("Idle detection is already %s",
- active ? "active" : "inactive");
- return FALSE;
- }
-
- if (! watcher->priv->enabled)
- {
- gs_debug ("Idle detection is disabled, cannot activate");
- return FALSE;
- }
-
- return _gs_watcher_set_active_internal (watcher, active);
-}
-
-gboolean
-gs_watcher_set_enabled (GSWatcher *watcher,
- gboolean enabled)
-{
- g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
-
- if (watcher->priv->enabled != enabled)
- {
- gboolean is_active = gs_watcher_get_active (watcher);
-
- watcher->priv->enabled = enabled;
-
- /* if we are disabling the watcher and we are
- active shut it down */
- if (! enabled && is_active)
- {
- _gs_watcher_set_active_internal (watcher, FALSE);
- }
- }
-
- return TRUE;
-}
-
-gboolean
-gs_watcher_get_enabled (GSWatcher *watcher)
-{
- gboolean enabled;
-
- g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE);
-
- enabled = watcher->priv->enabled;
-
- return enabled;
-}
-
-static gboolean
-on_idle_timeout (GSWatcher *watcher)
-{
- gboolean res;
-
- res = _gs_watcher_set_session_idle (watcher, TRUE);
-
- _gs_watcher_set_session_idle_notice (watcher, FALSE);
-
- /* try again if we failed i guess */
- return !res;
-}
-
-static void
-set_status (GSWatcher *watcher,
- guint status)
-{
- gboolean is_idle;
-
- if (! watcher->priv->active)
- {
- gs_debug ("GSWatcher: not active, ignoring status changes");
- return;
- }
-
- is_idle = (status == 3);
-
- if (!is_idle && !watcher->priv->idle_notice)
- {
- /* no change in idleness */
- return;
- }
-
- if (is_idle)
- {
- _gs_watcher_set_session_idle_notice (watcher, is_idle);
- /* queue an activation */
- if (watcher->priv->idle_id > 0)
- {
- g_source_remove (watcher->priv->idle_id);
- }
- watcher->priv->idle_id = g_timeout_add (watcher->priv->delta_notice_timeout,
- (GSourceFunc)on_idle_timeout,
- watcher);
- }
- else
- {
- /* cancel notice too */
- if (watcher->priv->idle_id > 0)
- {
- g_source_remove (watcher->priv->idle_id);
- watcher->priv->idle_id = 0;
- }
- _gs_watcher_set_session_idle (watcher, FALSE);
- _gs_watcher_set_session_idle_notice (watcher, FALSE);
- }
-}
-
-static void
-on_presence_status_changed (DBusGProxy *presence_proxy,
- guint status,
- GSWatcher *watcher)
-{
- set_status (watcher, status);
-}
-
-static void
-on_presence_status_text_changed (DBusGProxy *presence_proxy,
- const char *status_text,
- GSWatcher *watcher)
-{
- set_status_text (watcher, status_text);
-}
-
-static gboolean
-connect_presence_watcher (GSWatcher *watcher)
-{
- DBusGConnection *bus;
- GError *error;
- gboolean ret;
-
- ret = FALSE;
-
- error = NULL;
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (bus == NULL)
- {
- g_warning ("Unable to get session bus: %s", error->message);
- g_error_free (error);
- goto done;
- }
-
- error = NULL;
- watcher->priv->presence_proxy = dbus_g_proxy_new_for_name_owner (bus,
- "org.gnome.SessionManager",
- "/org/gnome/SessionManager/Presence",
- "org.gnome.SessionManager.Presence",
- &error);
- if (watcher->priv->presence_proxy != NULL)
- {
- DBusGProxy *proxy;
-
- dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
- "StatusChanged",
- G_TYPE_UINT,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
- "StatusChanged",
- G_CALLBACK (on_presence_status_changed),
- watcher,
- NULL);
- dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
- "StatusTextChanged",
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
- "StatusTextChanged",
- G_CALLBACK (on_presence_status_text_changed),
- watcher,
- NULL);
-
- proxy = dbus_g_proxy_new_from_proxy (watcher->priv->presence_proxy,
- "org.freedesktop.DBus.Properties",
- "/org/gnome/SessionManager/Presence");
- if (proxy != NULL)
- {
- guint status;
- const char *status_text;
- GValue value = { 0, };
-
- status = 0;
- status_text = NULL;
-
- error = NULL;
- dbus_g_proxy_call (proxy,
- "Get",
- &error,
- G_TYPE_STRING, "org.gnome.SessionManager.Presence",
- G_TYPE_STRING, "status",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID);
-
- if (error != NULL)
- {
- g_warning ("Couldn't get presence status: %s", error->message);
- g_error_free (error);
- goto done;
- }
- else
- {
- status = g_value_get_uint (&value);
- }
-
- g_value_unset (&value);
-
- error = NULL;
- dbus_g_proxy_call (proxy,
- "Get",
- &error,
- G_TYPE_STRING, "org.gnome.SessionManager.Presence",
- G_TYPE_STRING, "status-text",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID);
-
- if (error != NULL)
- {
- g_warning ("Couldn't get presence status text: %s", error->message);
- g_error_free (error);
- }
- else
- {
- status_text = g_value_get_string (&value);
- }
-
- set_status (watcher, status);
- set_status_text (watcher, status_text);
- }
- }
- else
- {
- g_warning ("Failed to get session presence proxy: %s", error->message);
- g_error_free (error);
- goto done;
- }
-
- ret = TRUE;
-
-done:
- return ret;
-}
-
-static void
-gs_watcher_init (GSWatcher *watcher)
-{
- watcher->priv = gs_watcher_get_instance_private (watcher);
-
- watcher->priv->enabled = TRUE;
- watcher->priv->active = FALSE;
-
- connect_presence_watcher (watcher);
-
- /* time before idle signal to send notice signal */
- watcher->priv->delta_notice_timeout = 10000;
-
- add_watchdog_timer (watcher, 600000);
-}
-
-static void
-gs_watcher_finalize (GObject *object)
-{
- GSWatcher *watcher;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_WATCHER (object));
-
- watcher = GS_WATCHER (object);
-
- g_return_if_fail (watcher->priv != NULL);
-
- remove_watchdog_timer (watcher);
-
- if (watcher->priv->idle_id > 0)
- {
- g_source_remove (watcher->priv->idle_id);
- watcher->priv->idle_id = 0;
- }
-
- watcher->priv->active = FALSE;
-
- if (watcher->priv->presence_proxy != NULL)
- {
- g_object_unref (watcher->priv->presence_proxy);
- }
-
- g_free (watcher->priv->status_message);
-
- G_OBJECT_CLASS (gs_watcher_parent_class)->finalize (object);
-}
-
-/* Figuring out what the appropriate XSetScreenSaver() parameters are
- (one wouldn't expect this to be rocket science.)
-*/
-static void
-disable_builtin_screensaver (GSWatcher *watcher,
- gboolean unblank_screen)
-{
- int current_server_timeout, current_server_interval;
- int current_prefer_blank, current_allow_exp;
- int desired_server_timeout, desired_server_interval;
- int desired_prefer_blank, desired_allow_exp;
-
- XGetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- ¤t_server_timeout,
- ¤t_server_interval,
- ¤t_prefer_blank,
- ¤t_allow_exp);
-
- desired_server_timeout = current_server_timeout;
- desired_server_interval = current_server_interval;
- desired_prefer_blank = current_prefer_blank;
- desired_allow_exp = current_allow_exp;
-
- desired_server_interval = 0;
-
- /* I suspect (but am not sure) that DontAllowExposures might have
- something to do with powering off the monitor as well, at least
- on some systems that don't support XDPMS? Who know... */
- desired_allow_exp = AllowExposures;
-
- /* When we're not using an extension, set the server-side timeout to 0,
- so that the server never gets involved with screen blanking, and we
- do it all ourselves. (However, when we *are* using an extension,
- we tell the server when to notify us, and rather than blanking the
- screen, the server will send us an X event telling us to blank.)
- */
- desired_server_timeout = 0;
-
- if (desired_server_timeout != current_server_timeout
- || desired_server_interval != current_server_interval
- || desired_prefer_blank != current_prefer_blank
- || desired_allow_exp != current_allow_exp)
- {
-
- gs_debug ("disabling server builtin screensaver:"
- " (xset s %d %d; xset s %s; xset s %s)",
- desired_server_timeout,
- desired_server_interval,
- (desired_prefer_blank ? "blank" : "noblank"),
- (desired_allow_exp ? "expose" : "noexpose"));
-
- XSetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- desired_server_timeout,
- desired_server_interval,
- desired_prefer_blank,
- desired_allow_exp);
-
- XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), FALSE);
- }
-
- if (unblank_screen)
- {
- /* Turn off the server builtin saver if it is now running. */
- XForceScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), ScreenSaverReset);
- }
-}
-
-
-/* This timer goes off every few minutes, whether the user is idle or not,
- to try and clean up anything that has gone wrong.
-
- It calls disable_builtin_screensaver() so that if xset has been used,
- or some other program (like xlock) has messed with the XSetScreenSaver()
- settings, they will be set back to sensible values (if a server extension
- is in use, messing with xlock can cause the screensaver to never get a wakeup
- event, and could cause monitor power-saving to occur, and all manner of
- heinousness.)
-
- */
-
-static gboolean
-watchdog_timer (GSWatcher *watcher)
-{
-
- disable_builtin_screensaver (watcher, FALSE);
-
- return TRUE;
-}
-
-GSWatcher *
-gs_watcher_new (void)
-{
- GSWatcher *watcher;
-
- watcher = g_object_new (GS_TYPE_WATCHER,
- NULL);
-
- return GS_WATCHER (watcher);
-}
diff --git a/src/gs-watcher.h b/src/gs-watcher.h
deleted file mode 100644
index 4f23f40..0000000
--- a/src/gs-watcher.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * Copyright (C) 2004-2005 William Jon McCann <mccann at jhu.edu>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Authors: William Jon McCann <mccann at jhu.edu>
- *
- */
-
-#ifndef __GS_WATCHER_H
-#define __GS_WATCHER_H
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-#define GS_TYPE_WATCHER (gs_watcher_get_type ())
-#define GS_WATCHER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GS_TYPE_WATCHER, GSWatcher))
-#define GS_WATCHER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GS_TYPE_WATCHER, GSWatcherClass))
-#define GS_IS_WATCHER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GS_TYPE_WATCHER))
-#define GS_IS_WATCHER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GS_TYPE_WATCHER))
-#define GS_WATCHER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GS_TYPE_WATCHER, GSWatcherClass))
-
-typedef struct GSWatcherPrivate GSWatcherPrivate;
-
-typedef struct
-{
- GObject parent;
- GSWatcherPrivate *priv;
-} GSWatcher;
-
-typedef struct
-{
- GObjectClass parent_class;
-
- gboolean (* idle_changed) (GSWatcher *watcher,
- gboolean is_idle);
- gboolean (* idle_notice_changed) (GSWatcher *watcher,
- gboolean in_effect);
-} GSWatcherClass;
-
-GType gs_watcher_get_type (void);
-
-GSWatcher * gs_watcher_new (void);
-gboolean gs_watcher_set_enabled (GSWatcher *watcher,
- gboolean enabled);
-gboolean gs_watcher_get_enabled (GSWatcher *watcher);
-gboolean gs_watcher_set_active (GSWatcher *watcher,
- gboolean active);
-gboolean gs_watcher_get_active (GSWatcher *watcher);
-
-G_END_DECLS
-
-#endif /* __GS_WATCHER_H */
diff --git a/src/test-watcher.c b/src/test-watcher.c
deleted file mode 100644
index afeb660..0000000
--- a/src/test-watcher.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * Authors: William Jon McCann <mccann at jhu.edu>
- *
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-
-#include <libxfce4util/libxfce4util.h>
-#include <gtk/gtk.h>
-
-#include "gs-watcher.h"
-#include "gs-debug.h"
-
-static gboolean
-watcher_idle_cb (GSWatcher *watcher,
- gboolean is_idle,
- gpointer data)
-{
- g_message ("Idle status changed: %s", is_idle ? "idle" : "not idle");
-
- /* return FALSE so that the idle watcher continues */
- return FALSE;
-}
-
-static gboolean
-watcher_idle_notice_cb (GSWatcher *watcher,
- gboolean is_idle,
- gpointer data)
-{
- g_message ("Idle notice status changed: %s", is_idle ? "idle" : "not idle");
-
- return TRUE;
-}
-
-static void
-connect_watcher_signals (GSWatcher *watcher)
-{
- g_signal_connect (watcher, "idle-changed",
- G_CALLBACK (watcher_idle_cb), NULL);
- g_signal_connect (watcher, "idle-notice-changed",
- G_CALLBACK (watcher_idle_notice_cb), NULL);
-}
-
-static void
-test_watcher (void)
-{
- GSWatcher *watcher;
-
- watcher = gs_watcher_new ();
- gs_watcher_set_enabled (watcher, TRUE);
- gs_watcher_set_active (watcher, TRUE);
-
- connect_watcher_signals (watcher);
-}
-
-int
-main (int argc,
- char **argv)
-{
- GError *error = NULL;
-
-#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
-# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-# endif
- textdomain (GETTEXT_PACKAGE);
-#endif
-
- if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
- {
- fprintf (stderr, "%s", error->message);
- g_error_free (error);
- exit (1);
- }
-
- gs_debug_init (TRUE, FALSE);
-
- test_watcher ();
-
- gtk_main ();
-
- gs_debug_shutdown ();
-
- return 0;
-}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list