From c8d356a2509db2f3da43fd13a4141dcaec3abf1e Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 8 Mar 2023 18:23:50 +0000 Subject: [PATCH] widget: Split out gtk_widget_ensure_allocate_on_children() allocate() should not be calling into ensure_allocate(), they do a similar job. In the end, the code does the same work, but it should be easier to follow now. --- gtk/gtkwidget.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 274b507b7c..4a765edf36 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -3871,6 +3871,28 @@ gtk_widget_adjust_size_allocation (GtkWidget *widget, } } +static void +gtk_widget_ensure_allocate_on_children (GtkWidget *widget) +{ + GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); + GtkWidget *child; + + g_assert (!priv->resize_needed); + g_assert (!priv->alloc_needed); + + if (!priv->alloc_needed_on_child) + return; + + priv->alloc_needed_on_child = FALSE; + + for (child = _gtk_widget_get_first_child (widget); + child != NULL; + child = _gtk_widget_get_next_sibling (child)) + { + gtk_widget_ensure_allocate (child); + } +} + /** * gtk_widget_allocate: * @widget: A `GtkWidget` @@ -4038,7 +4060,7 @@ gtk_widget_allocate (GtkWidget *widget, if (!alloc_needed && !size_changed && !baseline_changed) { - gtk_widget_ensure_allocate (widget); + gtk_widget_ensure_allocate_on_children (widget); goto skip_allocate; } @@ -10685,18 +10707,9 @@ gtk_widget_ensure_allocate (GtkWidget *widget) priv->allocated_size_baseline, gsk_transform_ref (priv->allocated_transform)); } - else if (priv->alloc_needed_on_child) + else { - GtkWidget *child; - - priv->alloc_needed_on_child = FALSE; - - for (child = _gtk_widget_get_first_child (widget); - child != NULL; - child = _gtk_widget_get_next_sibling (child)) - { - gtk_widget_ensure_allocate (child); - } + gtk_widget_ensure_allocate_on_children (widget); } }