widget: force adjustment method is one size is FILL
authorBenjamin Otte <otte@redhat.com>
Fri, 19 Nov 2021 23:46:08 +0000 (00:46 +0100)
committerBenjamin Otte <otte@redhat.com>
Sat, 20 Nov 2021 05:04:10 +0000 (06:04 +0100)
If halign=fill, force adjustment to height-for-width.
If valign=fill, force adjustment to width-for-height.
Otherwise look at request mode.

This way we don't try to adapt the filled dimension and only adjust
the one that is not set to fill.

gtk/gtkwidget.c
testsuite/reftests/wrap-margin-align-critical.ref.ui

index 73dc6b20be848f82bb83232fc3df5836fd34e065..65c62be6a07f728c11c9ff963898cf034db48e2d 100644 (file)
@@ -3832,7 +3832,9 @@ gtk_widget_adjust_size_allocation (GtkWidget     *widget,
   /* Note that adjust_for_align removes any margins from the
    * allocated sizes and possibly limits them to the natural sizes */
 
-  if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
+  if (priv->halign == GTK_ALIGN_FILL ||
+      (priv->valign != GTK_ALIGN_FILL &&
+       gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH))
     {
       gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL,
                           allocation->height + priv->margin.top + priv->margin.bottom,
index 04d550c82d852cac4ba8dbf9075a83fe129caac7..19daf3fe96710754a9a96be56f621f5427779949 100644 (file)
@@ -5,15 +5,10 @@
     <property name="default-height">300</property>
     <property name="decorated">0</property>
     <child>
-      <object class="GtkBox">
+      <object class="GtkLabel">
         <property name="halign">center</property>
-        <child>
-          <object class="GtkLabel">
-            <property name="halign">center</property>
-            <property name="label">Hello World</property>
-            <property name="wrap">True</property>
-          </object>
-        </child>
+        <property name="label">Hello World</property>
+        <property name="wrap">True</property>
       </object>
     </child>
   </object>