[gtk+/wip/ebassi/gsk-renderer: 66/135] widget: Fix compatibility fallbacks



commit 4c986971fd071c07c6740d0d5f376e2968c8e8d8
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Aug 1 16:19:31 2016 +0100

    widget: Fix compatibility fallbacks

 gtk/gtkwidget.c |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index ad17fd6..b9a1b2d 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -16079,13 +16079,19 @@ gtk_widget_get_render_node (GtkWidget   *widget,
   graphene_rect_init (&bounds, 0, 0, clip.width, clip.height);
   graphene_matrix_init_translate (&m, graphene_point3d_init (&tmp, clip.x, clip.y, 0.f));
 
+  /* Compatibility mode: if the widget does not have a render node, we draw
+   * using gtk_widget_draw() on a temporary node
+   */
   if (klass->get_render_node == NULL)
     {
       GskRenderNode *tmp;
       cairo_t *cr;
+      char *str;
+
+      str = g_strconcat ("Fallback<", G_OBJECT_TYPE_NAME (widget), ">", NULL);
 
       tmp = gsk_renderer_create_render_node (renderer);
-      gsk_render_node_set_name (tmp, "Draw Fallback");
+      gsk_render_node_set_name (tmp, str);
       gsk_render_node_set_bounds (tmp, &bounds);
       gsk_render_node_set_transform (tmp, &m);
       cr = gsk_render_node_get_draw_context (tmp);
@@ -16094,36 +16100,38 @@ gtk_widget_get_render_node (GtkWidget   *widget,
 
       cairo_destroy (cr);
 
+      g_free (str);
+
       node = tmp;
     }
   else
     {
       node = klass->get_render_node (widget, renderer);
 
-      if (klass->draw != NULL ||
-          g_signal_has_handler_pending (widget, widget_signals[DRAW], 0, FALSE))
+      /* Compatibility mode: if there's a ::draw signal handler, we add a
+       * child node with the contents of the handler
+       */
+      if (g_signal_has_handler_pending (widget, widget_signals[DRAW], 0, FALSE))
         {
           GskRenderNode *tmp;
           gboolean result;
           cairo_t *cr;
+          char *str;
+
+          str = g_strconcat ("DrawSignal<", G_OBJECT_TYPE_NAME (widget), ">", NULL);
 
           tmp = gsk_renderer_create_render_node (renderer);
-          gsk_render_node_set_name (tmp, "Draw Signal Handler");
+          gsk_render_node_set_name (tmp, str);
           gsk_render_node_set_bounds (tmp, &bounds);
           gsk_render_node_set_transform (tmp, &m);
           cr = gsk_render_node_get_draw_context (tmp);
 
-          if (g_signal_has_handler_pending (widget, widget_signals[DRAW], 0, FALSE))
-            {
-              g_signal_emit (widget, widget_signals[DRAW], 0, cr, &result);
-            }
-          else if (klass->draw != NULL)
-            {
-              klass->draw (widget, cr);
-            }
+          g_signal_emit (widget, widget_signals[DRAW], 0, cr, &result);
 
           cairo_destroy (cr);
 
+          g_free (str);
+
           if (node != NULL)
             {
               gsk_render_node_append_child (node, tmp);


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