[gtk+/wip/ebassi/gsk-renderer: 90/103] widget: Fix compatibility fallbacks



commit fa2f99ee03fc6cef70be12c3b67f5e01fd671d50
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 307e9ec..fa850f9 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -17492,13 +17492,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);
@@ -17507,36 +17513,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]