[Xfce4-commits] [xfce/xfce4-panel] 01/01: Fix child size allocation

noreply at xfce.org noreply at xfce.org
Mon Mar 13 21:52:44 CET 2017


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

andrzejr pushed a commit to branch master
in repository xfce/xfce4-panel.

commit 964a372239bfd069c5beafc5a1fac3452149a90c
Author: Viktor Odintsev <zakhams at gmail.com>
Date:   Sun Mar 5 20:55:04 2017 +0300

    Fix child size allocation
    
    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 6f646a4..b3e13bf 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)

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


More information about the Xfce4-commits mailing list