[SF#706] Send reconfigure to plugings on idle, not from spin button callback.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 2 May 2015 09:22:16 +0000 (12:22 +0300)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 2 May 2015 09:22:16 +0000 (12:22 +0300)
The reconfigure is heavy for some plugins and therefore duplicate reconfigure
may lead to button release loss, and that may be a disaster up to panel crash.

src/panel.c
src/private.h

index 791753a..3adf67e 100644 (file)
@@ -130,6 +130,11 @@ static void panel_stop_gui(LXPanel *self)
         g_source_remove(p->strut_update_queued);
         p->strut_update_queued = 0;
     }
+    if (p->reconfigure_queued)
+    {
+        g_source_remove(p->reconfigure_queued);
+        p->reconfigure_queued = 0;
+    }
 
     if (gtk_bin_get_child(GTK_BIN(self)))
     {
@@ -1624,12 +1629,19 @@ void panel_set_panel_configuration_changed(Panel *p)
     _panel_set_panel_configuration_changed(p->topgwin);
 }
 
-void _panel_set_panel_configuration_changed(LXPanel *panel)
+static gboolean _panel_idle_reconfigure(gpointer widget)
 {
-    Panel *p = panel->priv;
+    LXPanel *panel;
+    Panel *p;
     GList *plugins, *l;
+    GtkOrientation previous_orientation;
 
-    GtkOrientation previous_orientation = p->orientation;
+    if (g_source_is_destroyed(g_main_current_source()))
+        return FALSE;
+
+    panel = LXPANEL(widget);
+    p = panel->priv;
+    previous_orientation = p->orientation;
     p->orientation = (p->edge == EDGE_TOP || p->edge == EDGE_BOTTOM)
         ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
 
@@ -1679,6 +1691,19 @@ void _panel_set_panel_configuration_changed(LXPanel *panel)
     g_list_free(plugins);
     /* panel geometry changed? update panel background then */
     _panel_queue_update_background(panel);
+
+    p->reconfigure_queued = 0;
+
+    return FALSE;
+}
+
+void _panel_set_panel_configuration_changed(LXPanel *panel)
+{
+    if (panel->priv->reconfigure_queued)
+    {
+        return;
+    }
+    panel->priv->reconfigure_queued = g_idle_add(_panel_idle_reconfigure, panel);
 }
 
 static int
index c19bc02..432b873 100644 (file)
@@ -143,6 +143,7 @@ struct _Panel {
     guint background_update_queued;
     guint strut_update_queued;
     guint mouse_timeout;
+    guint reconfigure_queued;
     //gint dyn_space;                     /* Space for expandable plugins */
     //guint calculate_size_idle;          /* The idle handler for dyn_space calc */
     cairo_surface_t *surface;           /* Panel background */