[libhandy/wip/exalm/clamp: 1/2] clamp: Fix measuring child with for_size == -1




commit ed863f4144044e88d50cedfe72970410baf4a3a8
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Aug 13 17:23:12 2021 +0500

    clamp: Fix measuring child with for_size == -1
    
    See https://gitlab.gnome.org/GNOME/libadwaita/-/commit/b87bd3b53a13c5bbdb889190af456016ebe21108

 src/hdy-clamp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/hdy-clamp.c b/src/hdy-clamp.c
index 2409fc9a..f0a27684 100644
--- a/src/hdy-clamp.c
+++ b/src/hdy-clamp.c
@@ -147,7 +147,7 @@ get_child_size (HdyClamp *self,
 {
   GtkBin *bin = GTK_BIN (self);
   GtkWidget *child;
-  gint min = 0, max = 0, lower = 0, upper = 0;
+  gint min = 0, nat = 0, max = 0, lower = 0, upper = 0;
   gdouble amplitude, progress;
 
   child = gtk_bin_get_child (bin);
@@ -156,11 +156,14 @@ get_child_size (HdyClamp *self,
 
   if (gtk_widget_get_visible (child)) {
     if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
-      gtk_widget_get_preferred_width (child, &min, NULL);
+      gtk_widget_get_preferred_width (child, &min, &nat);
     else
-      gtk_widget_get_preferred_height (child, &min, NULL);
+      gtk_widget_get_preferred_height (child, &min, &nat);
   }
 
+  if (for_size < 0)
+    return nat;
+
   lower = MAX (MIN (self->tightening_threshold, self->maximum_size), min);
   max = MAX (lower, self->maximum_size);
   amplitude = max - lower;
@@ -175,9 +178,6 @@ get_child_size (HdyClamp *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]