From b5e7942f4e6c2fba87d5ef51b923aa7e0a641efe Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Wed, 24 Jun 2015 14:44:34 -0500 Subject: [PATCH 2/2] Do not exit on idle We cannot install a D-Bus service file because multiple programs can provide org.freedesktop.Notifications (gnome-shell, GNOME Flashback notification-daemon, mate-notification-daemon, Unity notify-osd, etc.) but only one can run at a given time. In order to avoid a race condition, none of them should register for D-Bus activation, but leave the session manager to launch the service provider for the given desktop. This means that we cannot shutdown upon idle, since there is nothing which will restart it when needed. --- xfce4-notifyd/xfce-notify-daemon.c | 57 -------------------------------------- 1 file changed, 57 deletions(-) diff --git a/xfce4-notifyd/xfce-notify-daemon.c b/xfce4-notifyd/xfce-notify-daemon.c index ec2972a..c15d911 100644 --- a/xfce4-notifyd/xfce-notify-daemon.c +++ b/xfce4-notifyd/xfce-notify-daemon.c @@ -62,8 +62,6 @@ struct _XfceNotifyDaemon gint changed_screen; - guint close_timeout; - guint32 last_notification_id; }; @@ -105,7 +103,6 @@ static void xfce_gdk_rectangle_largest_box(GdkRectangle *src1, static void xfce_notify_daemon_get_workarea(GdkScreen *screen, guint monitor, GdkRectangle *rect); -static gboolean xfce_notify_daemon_close_timeout(gpointer data); static gboolean notify_get_capabilities(XfceNotifyDaemon *xndaemon, gchar ***OUT_capabilities, @@ -322,10 +319,6 @@ xfce_notify_daemon_init(XfceNotifyDaemon *xndaemon) xndaemon->reserved_rectangles = NULL; xndaemon->monitors_workarea = NULL; - - xndaemon->close_timeout = - g_timeout_add_seconds(600, (GSourceFunc) xfce_notify_daemon_close_timeout, - xndaemon); } static void @@ -410,20 +403,6 @@ xfce_notify_daemon_window_closed(XfceNotifyWindow *window, g_tree_remove(xndaemon->active_notifications, id_p); - if (g_tree_nnodes(xndaemon->active_notifications) == 0) { - /* All notifications expired */ - /* Set a timeout to close xfce4-notifyd if it is idle - * for 10 minutes */ - - if(xndaemon->close_timeout) - g_source_remove(xndaemon->close_timeout); - - xndaemon->close_timeout = - g_timeout_add_seconds(600, - (GSourceFunc) xfce_notify_daemon_close_timeout, - xndaemon); - } - #ifdef USE_OLD_NOTIFICATION_CLOSED_SIGNATURE g_signal_emit(G_OBJECT(xndaemon), signals[SIG_NOTIFICATION_CLOSED], 0, GPOINTER_TO_UINT(id_p)); @@ -828,14 +807,6 @@ xfce_notify_daemon_update_reserved_rectangles(gpointer key, static gboolean -xfce_notify_daemon_close_timeout(gpointer data) -{ - notify_quit(XFCE_NOTIFY_DAEMON(data), NULL); - - return FALSE; -} - -static gboolean notify_get_capabilities(XfceNotifyDaemon *xndaemon, gchar ***OUT_capabilities, GError *error) @@ -851,17 +822,6 @@ notify_get_capabilities(XfceNotifyDaemon *xndaemon, (*OUT_capabilities)[i++] = g_strdup("x-canonical-private-icon-only"); (*OUT_capabilities)[i++] = NULL; - if (g_tree_nnodes(xndaemon->active_notifications) == 0) { - /* No active notifications, reset the close timeout */ - if(xndaemon->close_timeout) - g_source_remove(xndaemon->close_timeout); - - xndaemon->close_timeout = - g_timeout_add_seconds(600, - (GSourceFunc) xfce_notify_daemon_close_timeout, - xndaemon); - } - return TRUE; } @@ -997,12 +957,6 @@ notify_notify(XfceNotifyDaemon *xndaemon, gtk_widget_realize(GTK_WIDGET(window)); - /* Remove close timeout as we display a new notification */ - if(xndaemon->close_timeout) - g_source_remove(xndaemon->close_timeout); - - xndaemon->close_timeout = 0; - return TRUE; } @@ -1037,17 +991,6 @@ notify_get_server_information(XfceNotifyDaemon *xndaemon, *OUT_spec_version = g_strdup(NOTIFICATIONS_SPEC_VERSION); #endif - if (g_tree_nnodes(xndaemon->active_notifications) == 0) { - /* No active notifications, reset the close timeout */ - if(xndaemon->close_timeout) - g_source_remove(xndaemon->close_timeout); - - xndaemon->close_timeout = - g_timeout_add_seconds(600, - (GSourceFunc) xfce_notify_daemon_close_timeout, - xndaemon); - } - return TRUE; } -- 2.4.4