[Xfce4-commits] <xfce4-notifyd:master> Fix close timeout logic (bug #7467).

Jérôme Guelfucci noreply at xfce.org
Sat Jul 2 10:16:01 CEST 2011


Updating branch refs/heads/master
         to 46ad7630ed9a5dc78f7ee9307ba8268fe14bab5c (commit)
       from 191157bf9f11f78ea7b40e9f0a9dccdbd4025eeb (commit)

commit 46ad7630ed9a5dc78f7ee9307ba8268fe14bab5c
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Sat Jul 2 10:11:30 2011 +0200

    Fix close timeout logic (bug #7467).
    
    The timeout was initialized every time a new notification was displayed
    which makes no sense: now the timeout is initialized when all
    notifications expire.
    
    The tiemout is also removed when a new notification is shown and reset
    to its initial value when querying server information/specifications
    with no displayed notification.

 xfce4-notifyd/xfce-notify-daemon.c |   47 ++++++++++++++++++++++++++++-------
 1 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/xfce4-notifyd/xfce-notify-daemon.c b/xfce4-notifyd/xfce-notify-daemon.c
index cee6560..20ee47e 100644
--- a/xfce4-notifyd/xfce-notify-daemon.c
+++ b/xfce4-notifyd/xfce-notify-daemon.c
@@ -409,6 +409,21 @@ xfce_notify_daemon_window_closed(XfceNotifyWindow *window,
     xndaemon->reserved_rectangles[screen][monitor] = list;
 
     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));
@@ -838,6 +853,17 @@ 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;
 }
 
@@ -965,13 +991,11 @@ notify_notify(XfceNotifyDaemon *xndaemon,
 
     gtk_widget_realize(GTK_WIDGET(window));
 
-    /* Set a timeout to close xfce4-notifyd if it is idle for 10 minutes */
+    /* Remove close timeout as we display a new notification */
     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);
+    xndaemon->close_timeout = 0;
 
     return TRUE;
 }
@@ -1007,13 +1031,16 @@ notify_get_server_information(XfceNotifyDaemon *xndaemon,
     *OUT_spec_version = g_strdup(NOTIFICATIONS_SPEC_VERSION);
 #endif
 
-    /* Set a timeout to close xfce4-notifyd if it is idle for 10 minutes */
-    if(xndaemon->close_timeout)
-        g_source_remove(xndaemon->close_timeout);
+    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);
+        xndaemon->close_timeout =
+            g_timeout_add_seconds(600,
+                                  (GSourceFunc) xfce_notify_daemon_close_timeout,
+                                  xndaemon);
+    }
 
     return TRUE;
 }



More information about the Xfce4-commits mailing list