[gtk+/wip/otte/queue-resize: 19/32] widget: Add a resize_needed flag



commit 0f377b9fc321a4fb8202a1f2afb65c92e8d9abbd
Author: Benjamin Otte <otte redhat com>
Date:   Mon Sep 28 02:19:25 2015 +0200

    widget: Add a resize_needed flag
    
    ... and API to set and unset it.
    
    It is set when gtk_widget_queue_resize() is called.
    It is unset when gtk_widget_get_preferred_width/height() is called.
    
    So far it is not used.

 gtk/gtksizerequest.c   |    2 ++
 gtk/gtkwidget.c        |   12 ++++++++++++
 gtk/gtkwidgetprivate.h |    1 +
 3 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index 393af7c..eb46bd6 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -149,6 +149,8 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
   gint nat_baseline = -1;
   gboolean found_in_cache;
 
+  gtk_widget_ensure_resize (widget);
+
   if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE)
     for_size = -1;
 
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index eda11aa..5c82bca 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -16158,7 +16158,19 @@ gtk_widget_queue_resize_on_widget (GtkWidget *widget)
 {
   GtkWidgetPrivate *priv = widget->priv;
 
+  priv->resize_needed = TRUE;
   priv->alloc_needed = TRUE;
+}
+
+void
+gtk_widget_ensure_resize (GtkWidget *widget)
+{
+  GtkWidgetPrivate *priv = widget->priv;
+
+  if (!priv->resize_needed)
+    return;
+
+  priv->resize_needed = FALSE;
   _gtk_size_request_cache_clear (&priv->requests);
 }
 
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index aa69230..2e02308 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -167,6 +167,7 @@ void         _gtk_widget_set_shadowed       (GtkWidget *widget,
                                              gboolean   shadowed);
 gboolean     _gtk_widget_get_alloc_needed   (GtkWidget *widget);
 void         gtk_widget_queue_resize_on_widget (GtkWidget *widget);
+void         gtk_widget_ensure_resize       (GtkWidget *widget);
 void         _gtk_widget_draw               (GtkWidget *widget,
                                             cairo_t   *cr);
 void          _gtk_widget_scale_changed     (GtkWidget *widget);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]