[gtk+] widget: Track if a child needs an allocation
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] widget: Track if a child needs an allocation
- Date: Wed, 28 Oct 2015 18:59:03 +0000 (UTC)
commit 299600a7d4853b5df28e94a3dd8c9f52a2d84202
Author: Benjamin Otte <otte redhat com>
Date: Tue Sep 29 21:04:07 2015 +0200
widget: Track if a child needs an allocation
This is not used so far.
gtk/gtkwidget.c | 31 ++++++++++++++++++++++++++++++-
gtk/gtkwidgetprivate.h | 3 ++-
2 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 029fa63..fee05a7 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -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
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 566a562..814524c 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]