[clutter-gtk] gtk-clutter-embed: use draw() from Gtk+ as Expose event for the GDK backend



commit d3ce5bc8f0a8e2db7dcac3ce62d28b35aeed360c
Author: Lionel Landwerlin <llandwerlin gmail com>
Date:   Sat Aug 16 14:47:53 2014 +0100

    gtk-clutter-embed: use draw() from Gtk+ as Expose event for the GDK backend
    
    GtkClutterEmbed puts a filter on its GdkWindow to capture events and
    pass them to the ClutterBackend. That works well for X11, because the
    filter function receives an XEvent that can be directly fed to the
    ClutterX11Backend.
    
    For the GDK backend we can't do this because the filter function
    provides an untranslated event to the callee. Thus we can't give a
    valid GdkEvent to the ClutterGDKBackend.
    
    To work around this problem the current GtkClutterEmbed listen to the
    'event' signal of its widget, and puts fed them to the
    ClutterGDKBackend.
    
    The problem with this is that Gtk+ already does some filtering, mostly
    on Expose events. This means that initially a GtkClutterEmbed often
    appears unpainted with the Gdk backend of Clutter.
    
    This patch adds the draw() vfunc on the widget and triggers a
    clutter_actor_queue_redraw() upon call only for the GDK backend.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=734906

 clutter-gtk/gtk-clutter-embed.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/clutter-gtk/gtk-clutter-embed.c b/clutter-gtk/gtk-clutter-embed.c
index c309114..0ff2f5e 100644
--- a/clutter-gtk/gtk-clutter-embed.c
+++ b/clutter-gtk/gtk-clutter-embed.c
@@ -265,6 +265,19 @@ gtk_clutter_filter_func (GdkXEvent *native_event,
   return GDK_FILTER_CONTINUE;
 }
 
+static gboolean
+gtk_clutter_embed_draw (GtkWidget *widget, cairo_t *cr)
+{
+#if defined(CLUTTER_WINDOWING_GDK)
+  GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
+
+  if (clutter_check_windowing_backend (CLUTTER_WINDOWING_GDK))
+    clutter_actor_queue_redraw (priv->stage);
+#endif
+
+  return GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class)->draw (widget, cr);
+}
+
 static void
 gtk_clutter_embed_realize (GtkWidget *widget)
 {
@@ -940,6 +953,7 @@ gtk_clutter_embed_class_init (GtkClutterEmbedClass *klass)
 
   widget_class->style_updated = gtk_clutter_embed_style_updated;
   widget_class->size_allocate = gtk_clutter_embed_size_allocate;
+  widget_class->draw = gtk_clutter_embed_draw;
   widget_class->realize = gtk_clutter_embed_realize;
   widget_class->unrealize = gtk_clutter_embed_unrealize;
   widget_class->show = gtk_clutter_embed_show;


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