From: Benjamin Otte Date: Fri, 19 Nov 2021 22:19:14 +0000 (+0100) Subject: widget: Don't forget margins when adjusting X-Git-Tag: archive/raspbian/4.6.5+ds-1+rpi1~1^2~19^2~5^2~125^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7459d430eb5a8cd94462b0a1ad068e89384294f9;p=gtk4.git widget: Don't forget margins when adjusting This could lead to the wrong values being passed and computing invalid sizes which would then lead to very unhappy code. Test included. --- diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 788cfb6650..73dc6b20be 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -3846,7 +3846,7 @@ gtk_widget_adjust_size_allocation (GtkWidget *widget, &allocation->x, &allocation->width); gtk_widget_measure (widget, GTK_ORIENTATION_VERTICAL, - allocation->width, + allocation->width + priv->margin.left + priv->margin.right, &min_height, &natural_height, NULL, NULL); adjust_for_align (priv->valign, natural_height - priv->margin.top - priv->margin.bottom, @@ -3867,7 +3867,7 @@ gtk_widget_adjust_size_allocation (GtkWidget *widget, &allocation->y, &allocation->height); gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, - allocation->height, + allocation->height + priv->margin.top + priv->margin.bottom, &min_width, &natural_width, NULL, NULL); adjust_for_align (effective_align (priv->halign, _gtk_widget_get_direction (widget)), natural_width - priv->margin.left - priv->margin.right, diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build index eb277d8bf7..01f813bee5 100644 --- a/testsuite/reftests/meson.build +++ b/testsuite/reftests/meson.build @@ -527,6 +527,8 @@ testdata = [ # it is not in xfail since it succeeds on some platforms #'window-show-contents-on-map.ref.ui', #'window-show-contents-on-map.ui', + 'wrap-margin-align-critical.ref.ui', + 'wrap-margin-align-critical.ui', ] # These need to be fixed but the issue hasn't been tracked down. diff --git a/testsuite/reftests/wrap-margin-align-critical.ref.ui b/testsuite/reftests/wrap-margin-align-critical.ref.ui new file mode 100644 index 0000000000..04d550c82d --- /dev/null +++ b/testsuite/reftests/wrap-margin-align-critical.ref.ui @@ -0,0 +1,20 @@ + + + + 300 + 300 + 0 + + + center + + + center + Hello World + True + + + + + + diff --git a/testsuite/reftests/wrap-margin-align-critical.ui b/testsuite/reftests/wrap-margin-align-critical.ui new file mode 100644 index 0000000000..b69c770f09 --- /dev/null +++ b/testsuite/reftests/wrap-margin-align-critical.ui @@ -0,0 +1,21 @@ + + + + 300 + 300 + 0 + + + center + 50 + 50 + + + Hello World + True + + + + + +