[libadwaita/wip/exalm/fixes: 4/8] clamp: Fix measuring child with for_size == -1




commit b87bd3b53a13c5bbdb889190af456016ebe21108
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Aug 9 18:46:34 2021 +0500

    clamp: Fix measuring child with for_size == -1
    
    Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/225

 src/adw-clamp-layout.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/adw-clamp-layout.c b/src/adw-clamp-layout.c
index 93ca317e..101d33c2 100644
--- a/src/adw-clamp-layout.c
+++ b/src/adw-clamp-layout.c
@@ -129,11 +129,14 @@ get_child_size (AdwClampLayout *self,
                 int            *lower_threshold,
                 int            *upper_threshold)
 {
-  int min = 0, max = 0, lower = 0, upper = 0;
+  int min = 0, nat = 0, max = 0, lower = 0, upper = 0;
   double amplitude, progress;
 
   if (gtk_widget_get_visible (child))
-    gtk_widget_measure (child, self->orientation, -1, &min, NULL, NULL, NULL);
+    gtk_widget_measure (child, self->orientation, -1, &min, &nat, NULL, NULL);
+
+  if (for_size < 0)
+    return nat;
 
   lower = MAX (MIN (self->tightening_threshold, self->maximum_size), min);
   max = MAX (lower, self->maximum_size);
@@ -149,9 +152,6 @@ get_child_size (AdwClampLayout *self,
   if (upper_threshold)
     *upper_threshold = upper;
 
-  if (for_size < 0)
-    return 0;
-
   if (for_size <= lower)
     return for_size;
 


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