From 50e089349744f3244b5fba1823eb80f92f4d2dcd Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 20 Nov 2021 00:46:08 +0100 Subject: [PATCH] widget: force adjustment method is one size is FILL 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 | 4 +++- testsuite/reftests/wrap-margin-align-critical.ref.ui | 11 +++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 73dc6b20be..65c62be6a0 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -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, diff --git a/testsuite/reftests/wrap-margin-align-critical.ref.ui b/testsuite/reftests/wrap-margin-align-critical.ref.ui index 04d550c82d..19daf3fe96 100644 --- a/testsuite/reftests/wrap-margin-align-critical.ref.ui +++ b/testsuite/reftests/wrap-margin-align-critical.ref.ui @@ -5,15 +5,10 @@ 300 0 - + center - - - center - Hello World - True - - + Hello World + True