Merge branch 'more-size-allocation-fixes' into 'main'

widget: Skip popovers in allocation

See merge request GNOME/gtk!5615
This commit is contained in:
Matthias Clasen 2023-03-08 22:26:51 +00:00
commit 12858114a2

View File

@ -3871,6 +3871,29 @@ 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))
{
if (gtk_widget_should_layout (child))
gtk_widget_ensure_allocate (child);
}
}
/**
* gtk_widget_allocate:
* @widget: A `GtkWidget`
@ -4037,8 +4060,11 @@ gtk_widget_allocate (GtkWidget *widget,
size_changed = (priv->width != adjusted.width) || (priv->height != adjusted.height);
if (!alloc_needed && !size_changed && !baseline_changed)
goto skip_allocate;
{
gtk_widget_ensure_allocate_on_children (widget);
}
else
{
priv->width = adjusted.width;
priv->height = adjusted.height;
priv->baseline = baseline;
@ -4078,16 +4104,14 @@ gtk_widget_allocate (GtkWidget *widget,
if (size_changed)
gtk_accessible_bounds_changed (GTK_ACCESSIBLE (widget));
skip_allocate:
if (size_changed || baseline_changed)
gtk_widget_queue_draw (widget);
else if (transform_changed && priv->parent)
}
if (transform_changed && priv->parent)
gtk_widget_queue_draw (priv->parent);
out:
if (priv->alloc_needed_on_child)
gtk_widget_ensure_allocate (widget);
gtk_widget_pop_verify_invariants (widget);
}
@ -10637,7 +10661,10 @@ gtk_widget_set_alloc_needed (GtkWidget *widget)
break;
if (GTK_IS_NATIVE (widget))
{
gtk_native_queue_relayout (GTK_NATIVE (widget));
return;
}
widget = priv->parent;
if (widget == NULL)
@ -10685,18 +10712,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);
}
}