widget: Track if a child needs an allocation

This is not used so far.
This commit is contained in:
Benjamin Otte 2015-09-29 21:04:07 +02:00
parent f706891dd3
commit 299600a7d4
2 changed files with 32 additions and 2 deletions

View File

@ -4328,6 +4328,7 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->double_buffered = TRUE;
priv->redraw_on_alloc = TRUE;
priv->alloc_needed = TRUE;
priv->alloc_needed_on_child = TRUE;
switch (_gtk_widget_get_direction (widget))
{
@ -6043,6 +6044,7 @@ gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
#endif
gtk_widget_ensure_resize (widget);
priv->alloc_needed = FALSE;
priv->alloc_needed_on_child = FALSE;
size_changed |= (old_clip.width != priv->clip.width ||
old_clip.height != priv->clip.height);
@ -7167,6 +7169,7 @@ gtk_widget_draw (GtkWidget *widget,
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (!widget->priv->alloc_needed);
g_return_if_fail (!widget->priv->alloc_needed_on_child);
g_return_if_fail (cr != NULL);
cairo_save (cr);
@ -16214,13 +16217,39 @@ _gtk_widget_get_alloc_needed (GtkWidget *widget)
return widget->priv->alloc_needed;
}
static void
gtk_widget_set_alloc_needed (GtkWidget *widget)
{
GtkWidgetPrivate *priv = widget->priv;
priv->alloc_needed = TRUE;
do
{
if (priv->alloc_needed_on_child)
break;
priv->alloc_needed_on_child = TRUE;
if (!priv->visible)
break;
widget = priv->parent;
if (widget == NULL)
break;
priv = widget->priv;
}
while (TRUE);
}
void
gtk_widget_queue_resize_on_widget (GtkWidget *widget)
{
GtkWidgetPrivate *priv = widget->priv;
priv->resize_needed = TRUE;
priv->alloc_needed = TRUE;
gtk_widget_set_alloc_needed (widget);
}
void

View File

@ -73,7 +73,8 @@ struct _GtkWidgetPrivate
/* Queue-resize related flags */
guint resize_needed : 1; /* queue_resize() has been called but no get_preferred_size() yet */
guint alloc_needed : 1;
guint alloc_needed : 1; /* this widget needs a size_allocate() call */
guint alloc_needed_on_child : 1; /* 0 or more children - or this widget - need a size_allocate() call */
/* Expand-related flags */
guint need_compute_expand : 1; /* Need to recompute computed_[hv]_expand */