2008-02-29 Matthew Allum <mallum@openedhand.com>
authorMatthew Allum <mallum@openedhand.com>
Fri, 29 Feb 2008 00:18:29 +0000 (00:18 +0000)
committerMatthew Allum <mallum@openedhand.com>
Fri, 29 Feb 2008 00:18:29 +0000 (00:18 +0000)
        * clutter-gtk.pc.in:
        * configure.ac:
        Bump up to unstable 0.7 version and clutter req.

        * clutter-gtk/gtk-clutter-embed.c:
        * clutter-gtk/gtk-clutter-embed.h:
        Add clutter_gtk_init(), as to use new API to share DISPLAY and
        turn off Clutter 'automatic' event collection.
        Add methods for;
          expose    - Queue a Clutter redraw.
          map       - set Actor mapped flag.
          show/hide - Forward to stage also.
        Minor doc additions.

        * examples/gtk-clutter-events.c:
        Add some minor comments re when to call show_all().

        * examples/gtk-clutter-test.c:
        Fix event->actor mapping.

ChangeLog
clutter-gtk.pc.in
clutter-gtk/gtk-clutter-embed.c
clutter-gtk/gtk-clutter-embed.h
configure.ac
examples/gtk-clutter-events.c
examples/gtk-clutter-test.c

index e1d0575..b7070f9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2008-02-29  Matthew Allum  <mallum@openedhand.com>
+
+       * clutter-gtk.pc.in:
+       * configure.ac:
+        Bump up to unstable 0.7 version and clutter req.
+
+       * clutter-gtk/gtk-clutter-embed.c:
+       * clutter-gtk/gtk-clutter-embed.h:
+        Add clutter_gtk_init(), as to use new API to share DISPLAY and
+        turn off Clutter 'automatic' event collection. 
+        Add methods for;
+          expose    - Queue a Clutter redraw.
+          map       - set Actor mapped flag.
+          show/hide - Forward to stage also. 
+        Minor doc additions.
+          
+       * examples/gtk-clutter-events.c:
+        Add some minor comments re when to call show_all().        
+
+       * examples/gtk-clutter-test.c:
+        Fix event->actor mapping. 
+
 2008-02-21  Emmanuele Bassi  <ebassi@openedhand.com>
 
        * clutter-gtk/gtk-clutter-embed.c:
index abc5826..13a86ab 100644 (file)
@@ -6,6 +6,6 @@ includedir=${prefix}/include
 Name: clutter-gtk
 Description: GTK+ widget for Clutter
 Version: @VERSION@
-Libs: -L${libdir} -lclutter-gtk-0.6
+Libs: -L${libdir} -lclutter-gtk-0.7
 Cflags: -I${includedir}/clutter-0.6/clutter-gtk
-Requires: clutter-x11-0.6 gtk+-2.0
+Requires: clutter-x11-0.7 gtk+-2.0
index 28882e9..94594c0 100644 (file)
  * #GtkClutterEmbed widget. Instead, resize the widget using
  * gtk_widget_set_size_request().</note>
  *
+ * <note>You should only call #clutter_actor_show_all() after the
+ * widget itself has been shown</note>
+ *
+ * <note>Only a single #GtkClutterEmbed instace per application is
+ * currently supported</note>
+ *
  * Since: 0.6
  */
 
@@ -85,6 +91,29 @@ gtk_clutter_embed_dispose (GObject *gobject)
 }
 
 static void
+gtk_clutter_embed_show (GtkWidget *widget)
+{
+  GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
+
+  /* Make sure the widget is realised before we show */
+  gtk_widget_realize(widget);
+
+  GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class)->show (widget);
+
+  clutter_actor_show (priv->stage);
+}
+
+static void
+gtk_clutter_embed_hide (GtkWidget *widget)
+{
+  GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
+
+  GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class)->hide (widget);
+
+  clutter_actor_hide (priv->stage);
+}
+
+static void
 gtk_clutter_embed_realize (GtkWidget *widget)
 {
   GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv; 
@@ -117,9 +146,7 @@ gtk_clutter_embed_realize (GtkWidget *widget)
 
   clutter_x11_set_stage_foreign (CLUTTER_STAGE (priv->stage), 
                                  GDK_WINDOW_XID (widget->window));
-
-  /* allow a redraw here */
-  clutter_actor_queue_redraw (priv->stage);
+  clutter_redraw ();
 
   gtk_clutter_embed_send_configure (GTK_CLUTTER_EMBED (widget));
 }
@@ -202,6 +229,31 @@ gtk_clutter_embed_key_event (GtkWidget   *widget,
   return TRUE;
 }
 
+static gboolean
+gtk_clutter_embed_expose_event (GtkWidget *widget, GdkEventExpose *event)
+{
+  GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
+
+  if (CLUTTER_ACTOR_IS_VISIBLE (priv->stage))
+    clutter_actor_queue_redraw (priv->stage);
+
+  return TRUE;
+}
+
+static gboolean
+gtk_clutter_embed_map_event (GtkWidget      *widget,
+                             GdkEventAny     *event)
+{
+  GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
+
+  /* The backend wont get the XEvent as we go strait to do_event().
+   * So we have to make sure we set the event here.
+  */
+  CLUTTER_ACTOR_SET_FLAGS (priv->stage, CLUTTER_ACTOR_MAPPED);
+
+  return TRUE;
+}
+
 static void
 gtk_clutter_embed_class_init (GtkClutterEmbedClass *klass)
 {
@@ -214,10 +266,14 @@ gtk_clutter_embed_class_init (GtkClutterEmbedClass *klass)
 
   widget_class->size_allocate = gtk_clutter_embed_size_allocate;
   widget_class->realize = gtk_clutter_embed_realize;
+  widget_class->show = gtk_clutter_embed_show;
+  widget_class->hide = gtk_clutter_embed_hide;
   widget_class->button_press_event = gtk_clutter_embed_button_event;
   widget_class->button_release_event = gtk_clutter_embed_button_event;
   widget_class->key_press_event = gtk_clutter_embed_key_event;
   widget_class->key_release_event = gtk_clutter_embed_key_event;
+  widget_class->expose_event = gtk_clutter_embed_expose_event;
+  widget_class->map_event = gtk_clutter_embed_map_event;
 }
 
 static void
@@ -244,9 +300,30 @@ gtk_clutter_embed_init (GtkClutterEmbed *embed)
 }
 
 /**
+ * gtk_clutter_init:
+ *
+ * This function should be called instead of #clutter_init() and after
+ * #gtk_init()
+ *
+ * Return value: 1 on success, < 0 on failure.
+ *
+ * Since: 0.8
+ */
+ClutterInitError
+gtk_clutter_init (int *argc, char ***argv)
+{
+  clutter_x11_set_display (GDK_DISPLAY());
+  clutter_x11_disable_event_retrieval ();
+
+  /* FIXME: call gtk_init() here? */
+
+  return clutter_init (argc, argv);
+}
+
+/**
  * gtk_clutter_embed_new:
  *
- * FIXME
+ * Creates a new embedded Clutter widget.
  *
  * Return value: the newly created #GtkClutterEmbed
  *
index 1d13756..67318cc 100644 (file)
@@ -79,6 +79,8 @@ GType         gtk_clutter_embed_get_type  (void) G_GNUC_CONST;
 GtkWidget *   gtk_clutter_embed_new       (void);
 ClutterActor *gtk_clutter_embed_get_stage (GtkClutterEmbed *embed);
 
+ClutterInitError gtk_clutter_init (int *argc, char ***argv);
+
 G_END_DECLS
 
 #endif /* __GTK_CLUTTER_EMBED_H__ */
index cda6865..2623739 100644 (file)
@@ -2,7 +2,7 @@
 # An odd micro number indicates in-progress development, (eg. from CVS)
 # An even micro number indicates a released version.
 m4_define([clutter_major_version], [0])
-m4_define([clutter_minor_version], [6])
+m4_define([clutter_minor_version], [7])
 m4_define([clutter_micro_version], [0])
 
 m4_define([clutter_version],
@@ -67,9 +67,9 @@ AC_FUNC_MALLOC
 AC_FUNC_MMAP
 AC_CHECK_FUNCS([memset munmap strcasecmp strdup])
 
-CLUTTER_REQUIRED=0.6.0
+CLUTTER_REQUIRED=0.7.0
 
-PKG_CHECK_MODULES(CLUTTER, clutter-x11-0.6 >= $CLUTTER_REQUIRED)
+PKG_CHECK_MODULES(CLUTTER, clutter-x11-0.7 >= $CLUTTER_REQUIRED)
 AC_SUBST(CLUTTER_CFLAGS)
 AC_SUBST(CLUTTER_LIBS)
 
index 6235d99..78aa952 100644 (file)
@@ -118,9 +118,8 @@ main (gint argc, gchar **argv)
   ClutterColor   stage_color = {255, 255, 255, 255};
   ClutterColor   text_color = {0, 0, 0, 255};
 
-  clutter_init (&argc, &argv);
-  
   gtk_init (&argc, &argv);
+  gtk_clutter_init (&argc, &argv);
 
   /* Create the inital gtk window and widgets, just like normal */
   widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -216,9 +215,13 @@ main (gint argc, gchar **argv)
   gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0);
   g_signal_connect (button, "value-changed", G_CALLBACK (on_opacity_changed), app);
 
-  clutter_actor_show_all (app->stage);
   gtk_widget_show_all (app->window);
 
+  /* Only show/show_all the stage after parent show. widget_show will call
+   * show on the stage.
+  */
+  clutter_actor_show_all (app->stage);
+
   gtk_main ();
   
   return 0;
index 7ab6df8..173d4e9 100644 (file)
@@ -28,14 +28,14 @@ input_cb (ClutterStage *stage,
 {
   if (event->type == CLUTTER_BUTTON_PRESS)
     {
-      ClutterActor *actor;
+      ClutterActor *a;
       gint x, y;
 
       clutter_event_get_coords (event, &x, &y);
 
-      actor = clutter_stage_get_actor_at_pos (stage, x, y);
-      if (actor)
-       clutter_actor_hide (actor);
+      a = clutter_stage_get_actor_at_pos (stage, x, y);
+      if (a && (CLUTTER_IS_TEXTURE (a) || CLUTTER_IS_CLONE_TEXTURE (a)))
+       clutter_actor_hide (a);
     }
   else if (event->type == CLUTTER_KEY_PRESS)
     {
@@ -114,8 +114,8 @@ main (int argc, char *argv[])
   SuperOH         *oh;
   gint             i;
 
-  clutter_init (&argc, &argv);
   gtk_init (&argc, &argv);
+  gtk_clutter_init (&argc, &argv);
 
   pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL);
 
@@ -198,7 +198,7 @@ main (int argc, char *argv[])
   /* Add the group to the stage */
   clutter_group_add (CLUTTER_GROUP (stage), CLUTTER_ACTOR(oh->group));
 
-  /* Show everying ( and map window ) */
+  /* Show our group, widget show will show the stage */
   clutter_actor_show_all (CLUTTER_ACTOR (oh->group));
 
   g_signal_connect (stage, "button-press-event",