[Xfce4-commits] [panel-plugins/xfce4-statusnotifier-plugin] 01/02: Defer dbus sync with items

noreply at xfce.org noreply at xfce.org
Fri Oct 27 09:05:09 CEST 2017


This is an automated email from the git hooks/post-receive script.

n   i   n   e   t   l   s       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 panel-plugins/xfce4-statusnotifier-plugin.

commit 0b5776b9f3d9d9af1e622050e54081961674bfc6
Author: Viktor Odintsev <ninetls at xfce.org>
Date:   Fri Oct 27 00:59:54 2017 +0300

    Defer dbus sync with items
    
    Sometimes querying SNI properties may return outdated values
    if query was made right after signal emission or application start.
    
    Deferment queries for 10ms fixes this problem.
    Plasma Workspace uses the same approach.
---
 panel-plugin/sn-item.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/panel-plugin/sn-item.c b/panel-plugin/sn-item.c
index 918758c..cfb8e94 100644
--- a/panel-plugin/sn-item.c
+++ b/panel-plugin/sn-item.c
@@ -72,6 +72,7 @@ struct _SnItem
   GCancellable        *cancellable;
   GDBusProxy          *item_proxy;
   GDBusProxy          *properties_proxy;
+  guint                properties_timeout;
 
   gchar               *bus_name;
   gchar               *object_path;
@@ -249,6 +250,7 @@ sn_item_init (SnItem *item)
   item->cancellable = g_cancellable_new ();
   item->item_proxy = NULL;
   item->properties_proxy = NULL;
+  item->properties_timeout = 0;
 
   item->bus_name = NULL;
   item->object_path = NULL;
@@ -285,6 +287,9 @@ sn_item_finalize (GObject *object)
 
   g_object_unref (item->cancellable);
 
+  if (item->properties_timeout != 0)
+    g_source_remove (item->properties_timeout);
+
   if (item->properties_proxy != NULL)
     g_object_unref (item->properties_proxy);
 
@@ -516,11 +521,12 @@ sn_item_start (SnItem *item)
 
 
 
-void
-sn_item_invalidate (SnItem *item)
+static gboolean
+sn_item_perform_invalidate (gpointer user_data)
 {
-  g_return_if_fail (XFCE_IS_SN_ITEM (item));
-  g_return_if_fail (item->properties_proxy != NULL);
+  SnItem *item = user_data;
+
+  item->properties_timeout = 0;
 
   g_dbus_proxy_call (item->properties_proxy,
                      "GetAll",
@@ -530,6 +536,22 @@ sn_item_invalidate (SnItem *item)
                      item->cancellable,
                      sn_item_get_all_properties_result,
                      item);
+
+  return G_SOURCE_REMOVE;
+}
+
+
+
+void
+sn_item_invalidate (SnItem *item)
+{
+  g_return_if_fail (XFCE_IS_SN_ITEM (item));
+  g_return_if_fail (item->properties_proxy != NULL);
+
+  /* same approach as in Plasma Workspace */
+  if (item->properties_timeout != 0)
+    g_source_remove (item->properties_timeout);
+  item->properties_timeout = g_timeout_add (10, sn_item_perform_invalidate, item);
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list