[gtk+/wip/simple-draw3: 16/23] GtkWidget: Avoid widget->priv->alloc_needed when propagating exposes



commit 4c5a5bb6d31f9d886fd1a281f8d372a710cc17c5
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Apr 26 15:33:22 2013 +0200

    GtkWidget: Avoid widget->priv->alloc_needed when propagating exposes
    
    It turns out that at various times we currently propagate draws
    when the child has alloc_needed set. We need to fix these, but
    we don't want that to block the current work, so for now we just
    avoid that assert when we propagate draws (its what we used to
    do after all).

 gtk/gtkcontainer.c     |    2 +-
 gtk/gtkwidget.c        |   73 +++++++++++++++++++++++++++---------------------
 gtk/gtkwidgetprivate.h |    2 +
 3 files changed, 44 insertions(+), 33 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 2a95bd2..5b9449a 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -3435,7 +3435,7 @@ gtk_container_propagate_draw (GtkContainer   *container,
 
   cairo_translate (cr, x, y);
 
-  gtk_widget_draw (child, cr);
+  _gtk_widget_draw (child, cr);
 
   cairo_restore (cr);
 }
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 4255deb..1090b64 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6489,35 +6489,9 @@ _gtk_widget_draw_windows (GdkWindow *window,
   cairo_restore (cr);
 }
 
-/**
- * gtk_widget_draw:
- * @widget: the widget to draw. It must be drawable (see
- *   gtk_widget_is_drawable()) and a size must have been allocated.
- * @cr: a cairo context to draw to
- *
- * Draws @widget to @cr. The top left corner of the widget will be
- * drawn to the currently set origin point of @cr.
- *
- * You should pass a cairo context as @cr argument that is in an
- * original state. Otherwise the resulting drawing is undefined. For
- * example changing the operator using cairo_set_operator() or the
- * line width using cairo_set_line_width() might have unwanted side
- * effects.
- * You may however change the context's transform matrix - like with
- * cairo_scale(), cairo_translate() or cairo_set_matrix() and clip
- * region with cairo_clip() prior to calling this function. Also, it
- * is fine to modify the context with cairo_save() and
- * cairo_push_group() prior to calling this function.
- *
- * <note><para>Special purpose widgets may contain special code for
- * rendering to the screen and might appear differently on screen
- * and when rendered using gtk_widget_draw().</para></note>
- *
- * Since: 3.0
- **/
 void
-gtk_widget_draw (GtkWidget *widget,
-                 cairo_t   *cr)
+_gtk_widget_draw (GtkWidget *widget,
+                 cairo_t   *cr)
 {
   GdkWindow *window, *child_window;
   gpointer child_data;
@@ -6543,9 +6517,6 @@ gtk_widget_draw (GtkWidget *widget,
    * order you generally use a windowed widget where you control
    * the window hierarchy.
    */
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (!widget->priv->alloc_needed);
-  g_return_if_fail (cr != NULL);
 
   cairo_save (cr);
 
@@ -6605,6 +6576,44 @@ gtk_widget_draw (GtkWidget *widget,
   cairo_restore (cr);
 }
 
+
+/**
+ * gtk_widget_draw:
+ * @widget: the widget to draw. It must be drawable (see
+ *   gtk_widget_is_drawable()) and a size must have been allocated.
+ * @cr: a cairo context to draw to
+ *
+ * Draws @widget to @cr. The top left corner of the widget will be
+ * drawn to the currently set origin point of @cr.
+ *
+ * You should pass a cairo context as @cr argument that is in an
+ * original state. Otherwise the resulting drawing is undefined. For
+ * example changing the operator using cairo_set_operator() or the
+ * line width using cairo_set_line_width() might have unwanted side
+ * effects.
+ * You may however change the context's transform matrix - like with
+ * cairo_scale(), cairo_translate() or cairo_set_matrix() and clip
+ * region with cairo_clip() prior to calling this function. Also, it
+ * is fine to modify the context with cairo_save() and
+ * cairo_push_group() prior to calling this function.
+ *
+ * <note><para>Special purpose widgets may contain special code for
+ * rendering to the screen and might appear differently on screen
+ * and when rendered using gtk_widget_draw().</para></note>
+ *
+ * Since: 3.0
+ **/
+void
+gtk_widget_draw (GtkWidget *widget,
+                 cairo_t   *cr)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (!widget->priv->alloc_needed);
+  g_return_if_fail (cr != NULL);
+
+  _gtk_widget_draw (widget, cr);
+}
+
 static gboolean
 gtk_widget_real_key_press_event (GtkWidget         *widget,
                                 GdkEventKey       *event)
@@ -6910,7 +6919,7 @@ gtk_widget_send_expose (GtkWidget *widget,
   gtk_cairo_set_event (cr, &event->expose);
 
   if (event->expose.window == widget->priv->window)
-    gtk_widget_draw (widget, cr);
+    _gtk_widget_draw (widget, cr);
   else
     _gtk_widget_draw_windows (event->expose.window, cr, 0, 0);
 
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 167f5a9..b4e3bed 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -45,6 +45,8 @@ void         _gtk_widget_set_shadowed       (GtkWidget *widget,
 gboolean     _gtk_widget_get_alloc_needed   (GtkWidget *widget);
 void         _gtk_widget_set_alloc_needed   (GtkWidget *widget,
                                              gboolean   alloc_needed);
+void         _gtk_widget_draw               (GtkWidget *widget,
+                                            cairo_t   *cr);
 
 void         _gtk_widget_add_sizegroup         (GtkWidget    *widget,
                                                gpointer      group);


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