[PATCH 0/1] Fix xfce4-panel plugin size allocation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/1] Fix xfce4-panel plugin size allocation

Viktor Odintsev
Each plugin on the panel takes at least 1 px as defined in panel-itembar.c:

  if (G_UNLIKELY (child_len < 1))
    child_len = 1;

With expandable plugins it leads to incorrect total length calculation.

The easiest way to reproduce it is to create a new panel with the following plugins:

1: Window buttons without handle
2: Expandable separator
3: Any other plugin to observe the bug (e.g. clock)

Without any open windows the first plugin will take 1px which wasn't taken into account on `expand_len_avail` calculation so the rest plugins will be shifted in 1 px.

This patch fixes this issue.

Viktor Odintsev (1):
  Fix child size allocation

 panel/panel-itembar.c | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

--
2.12.0

_______________________________________________
Xfce4-dev mailing list
[hidden email]
https://mail.xfce.org/mailman/listinfo/xfce4-dev
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/1] Fix child size allocation

Viktor Odintsev
Each child takes at least 1 px on the panel which led to an
incorrect total length calculation.
---
 panel/panel-itembar.c | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/panel/panel-itembar.c b/panel/panel-itembar.c
index 6f646a4b..b3e13bf4 100644
--- a/panel/panel-itembar.c
+++ b/panel/panel-itembar.c
@@ -468,12 +468,16 @@ panel_itembar_size_allocate (GtkWidget     *widget,
   gint               x, y;
   gint               x_init, y_init;
   gboolean           expand_children_fit;
-  gint               new_len;
+  gint               new_len, sub_len;
   gint               child_len, child_len_min;
   gint               row_max_size;
   gint               col_count;
   gint               rows_size;
 
+  #define CHILD_MIN_ALLOC_LEN(child_len) \
+    if (G_UNLIKELY ((child_len) < 1)) \
+      (child_len) = 1;
+
   /* the maximum allocation is limited by that of the
    * panel window, so take over the assigned allocation */
   gtk_widget_set_allocation (widget, allocation);
@@ -511,6 +515,10 @@ panel_itembar_size_allocate (GtkWidget     *widget,
           else
             gtk_widget_get_preferred_height (child->widget, &child_len_min, &child_len);
 
+          /* child will allocate at least 1 pixel */
+          CHILD_MIN_ALLOC_LEN (child_len);
+          CHILD_MIN_ALLOC_LEN (child_len_min);
+
           if (G_UNLIKELY (child->option == CHILD_OPTION_SMALL
                           && itembar->nrows > 1))
             {
@@ -635,6 +643,10 @@ panel_itembar_size_allocate (GtkWidget     *widget,
           panel_assert (expand_len_req > 0);
           new_len = expand_len_avail * child_len / expand_len_req;
 
+          CHILD_MIN_ALLOC_LEN (child_len);
+          CHILD_MIN_ALLOC_LEN (child_len_min);
+          CHILD_MIN_ALLOC_LEN (new_len);
+
           expand_len_req -= child_len;
           expand_len_avail -= new_len;
 
@@ -645,16 +657,24 @@ panel_itembar_size_allocate (GtkWidget     *widget,
         {
           /* equally shrink all shrinking plugins */
           panel_assert (shrink_len_avail > 0);
-          new_len = MIN (shrink_len_req * (child_len - child_len_min) / shrink_len_avail,
+          sub_len = MIN (shrink_len_req * (child_len - child_len_min) / shrink_len_avail,
                          child_len - child_len_min);
-          shrink_len_req -= new_len;
+          new_len = child_len - sub_len;
+
+          CHILD_MIN_ALLOC_LEN (child_len);
+          CHILD_MIN_ALLOC_LEN (child_len_min);
+          CHILD_MIN_ALLOC_LEN (new_len);
+
+          shrink_len_req -= sub_len;
           shrink_len_avail -= (child_len - child_len_min);
 
-          child_len -= new_len;
+          child_len = new_len;
+        }
+      else
+        {
+          CHILD_MIN_ALLOC_LEN (child_len);
+          CHILD_MIN_ALLOC_LEN (child_len_min);
         }
-
-      if (G_UNLIKELY (child_len < 1))
-        child_len = 1;
 
       if (child->option == CHILD_OPTION_SMALL
           && itembar->nrows > 1)
--
2.12.0

_______________________________________________
Xfce4-dev mailing list
[hidden email]
https://mail.xfce.org/mailman/listinfo/xfce4-dev