[libhandy] stackable-box: Fix end child allocation during mode transitions



commit cf54242a05c06e27f4cabe42f8663bd2fdda144b
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue Jun 23 19:13:48 2020 +0500

    stackable-box: Fix end child allocation during mode transitions
    
    It was just completely wrong.
    
    1. The initial current_pad value was the right edge of the visible child.
    2. Despite that, we went from the last child to the visible one and not the
       other way.
    3. We decrement current_pad instead of incrementing it, matching the list
       traverse direction.
    
    This already sounds like it will break horribly, but we also had a bug
    balancing all of that:
    
    4. We decrement current_pad by 0 instead of the proper child width, because
       we do it before the width is set.
    
    This leads to all of the end children getting the same x coordinate,
    overlapping each other.
    
    Signed-off-by: Alexander Mikhaylenko <alexm gnome org>

 src/hdy-stackable-box.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/hdy-stackable-box.c b/src/hdy-stackable-box.c
index 18415129..4a0be770 100644
--- a/src/hdy-stackable-box.c
+++ b/src/hdy-stackable-box.c
@@ -1597,15 +1597,13 @@ hdy_stackable_box_size_allocate_folded (HdyStackableBox *self,
   /* Allocate ending children. */
   current_pad = end_position;
 
-  for (children = g_list_last (directed_children); children; children = children->prev) {
-    child_info = children->data;
+  if (!children || !children->next)
+    return;
 
-    if (child_info == visible_child)
-      break;
+  for (children = children->next; children; children = children->next) {
+    child_info = children->data;
 
     if (orientation == GTK_ORIENTATION_HORIZONTAL) {
-      current_pad -= child_info->alloc.width;
-
       child_info->alloc.width = box_homogeneous ?
         max_child_size :
         child_info->nat.width;
@@ -1613,10 +1611,10 @@ hdy_stackable_box_size_allocate_folded (HdyStackableBox *self,
       child_info->alloc.x = current_pad;
       child_info->alloc.y = 0;
       child_info->visible = child_info->alloc.x < allocation->width;
+
+      current_pad += child_info->alloc.width;
     }
     else {
-      current_pad -= child_info->alloc.height;
-
       child_info->alloc.width = allocation->width;
       child_info->alloc.height = box_homogeneous ?
         max_child_size :
@@ -1624,6 +1622,8 @@ hdy_stackable_box_size_allocate_folded (HdyStackableBox *self,
       child_info->alloc.x = 0;
       child_info->alloc.y = current_pad;
       child_info->visible = child_info->alloc.y < allocation->height;
+
+      current_pad += child_info->alloc.height;
     }
   }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]