Fix panel flicker with some window managers.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Sun, 20 Nov 2016 23:27:19 +0000 (01:27 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Sun, 20 Nov 2016 23:27:19 +0000 (01:27 +0200)
ChangeLog
src/icon-grid.c
src/panel.c

index 9b79f8f..a21a14e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,8 @@
 0.9.1
 -------------------------------------------------------------------------
-* Fixed build without ALSA.
+* Fixed build failure without ALSA.
 * Added alternative mixers if build using OSS.
+* Fixed panel flicker with some window managers.
 
 0.9.0
 -------------------------------------------------------------------------
index b3b1d62..2177971 100644 (file)
@@ -24,6 +24,7 @@
 #include <string.h>
 
 #include "icon-grid.h"
+#include "panel.h" /* for panel_get_height() */
 #include "gtk-compat.h"
 
 /* Properties */
@@ -84,7 +85,25 @@ static void icon_grid_element_check_requisition(PanelIconGrid *ig,
     requisition->height = ig->child_height;
 }
 
-static void panel_icon_grid_calculate_size(PanelIconGrid *ig, GtkRequisition *requisition);
+static void panel_icon_grid_size_request(GtkWidget *widget,
+                                         GtkRequisition *requisition);
+
+static gboolean check_for_recalc(PanelIconGrid *ig)
+{
+    GtkWidget *toplevel = gtk_widget_get_toplevel((GtkWidget *)ig);
+
+    if (LX_IS_PANEL(toplevel))
+    {
+        gint height = panel_get_height((LXPanel *)toplevel);
+
+        if (height != ig->target_dimension)
+        {
+            ig->target_dimension = height;
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
 
 /* Establish the widget placement of an icon grid. */
 static void panel_icon_grid_size_allocate(GtkWidget *widget,
@@ -101,7 +120,6 @@ static void panel_icon_grid_size_allocate(GtkWidget *widget,
     int x_delta;
     guint next_coord;
     guint x, y;
-    gboolean need_recalc = FALSE;
     GList *ige;
     GtkWidget *child;
 
@@ -146,18 +164,12 @@ static void panel_icon_grid_size_allocate(GtkWidget *widget,
     child_height = ig->child_height;
     if (ig->orientation == GTK_ORIENTATION_HORIZONTAL && allocation->height > 1)
     {
-        if (ig->target_dimension != allocation->height)
-            need_recalc = TRUE;
-        ig->target_dimension = allocation->height;
         /* Don't allow children go out of the grid */
         if ((child_height + (int)border * 2) > allocation->height)
             child_height = MAX(1, allocation->height - 2 * border);
     }
     else if (ig->orientation == GTK_ORIENTATION_VERTICAL && allocation->width > 1)
     {
-        if (ig->target_dimension != allocation->width)
-            need_recalc = TRUE;
-        ig->target_dimension = allocation->width;
         /* Don't allow children go out of the grid */
         if ((child_width + (int)border * 2) > allocation->width)
             child_width = MAX(1, allocation->width - 2 * border);
@@ -165,8 +177,8 @@ static void panel_icon_grid_size_allocate(GtkWidget *widget,
 
     /* FIXME: is there any sense to recheck rows and columns again?
        GTK+ should have it done right before this call. */
-    if (need_recalc)
-        panel_icon_grid_calculate_size(ig, &req);
+    if (check_for_recalc(ig))
+        panel_icon_grid_size_request(widget, &req);
 
     /* Get the constrained child geometry if the allocated geometry is insufficient.
      * All children are still the same size and share equally in the deficit. */
index 0e3cdb0..bff3667 100644 (file)
@@ -303,8 +303,11 @@ static void lxpanel_size_allocate(GtkWidget *widget, GtkAllocation *a)
 
     /* some WM like mwm are too generous giving us space more that requested
        so let correct it right now, as much as we can */
-    a->width = MAX(8, MIN(p->cw, a->width));
-    a->height = MAX(8, MIN(p->ch, a->height));
+    rect.x = a->x;
+    rect.y = a->y;
+    rect.width = MAX(8, MIN(p->cw, a->width));
+    rect.height = MAX(8, MIN(p->ch, a->height));
+    _calculate_position(panel, &rect);
 
     GTK_WIDGET_CLASS(lxpanel_parent_class)->size_allocate(widget, a);
 
@@ -316,10 +319,8 @@ static void lxpanel_size_allocate(GtkWidget *widget, GtkAllocation *a)
     if (!gtk_widget_get_realized(widget))
         return;
 
-    rect = *a;
     /* get real coords since a contains 0, 0 */
     gdk_window_get_origin(gtk_widget_get_window(widget), &x, &y);
-    _calculate_position(panel, &rect);
     p->ax = rect.x;
     p->ay = rect.y;
 
@@ -327,7 +328,7 @@ static void lxpanel_size_allocate(GtkWidget *widget, GtkAllocation *a)
     {
         p->aw = a->width;
         p->ah = a->height;
-        gdk_window_move_resize(gtk_widget_get_window(widget), p->ax, p->ay, p->aw, p->ah);
+        gtk_window_move(GTK_WINDOW(widget), p->ax, p->ay);
         /* SF bug #708: strut update does not work while in size allocation */
         if (!panel->priv->strut_update_queued)
             panel->priv->strut_update_queued = g_idle_add_full(G_PRIORITY_HIGH,