[embed] Do NOT realize from GtkWidgetClass::show
authorChristian Persch <chpe@gnome.org>
Mon, 30 Mar 2009 18:19:45 +0000 (20:19 +0200)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Tue, 14 Apr 2009 13:11:56 +0000 (14:11 +0100)
Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1185

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>

clutter-gtk/gtk-clutter-embed.c

index 04519c5..cbeeb86 100644 (file)
@@ -131,11 +131,8 @@ gtk_clutter_embed_show (GtkWidget *widget)
 {
   GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
 
-  /* Make sure the widget is realised before we show */
-  if (!GTK_WIDGET_REALIZED (widget))
-    gtk_widget_realize (widget);
-
-  clutter_actor_show (priv->stage);
+  if (GTK_WIDGET_REALIZED (widget))
+    clutter_actor_show (priv->stage);
 
   GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class)->show (widget);
 }
@@ -157,6 +154,24 @@ gtk_clutter_embed_realize (GtkWidget *widget)
   GdkWindowAttr attributes;
   int attributes_mask;
   
+  /* we must realize the stage to get it ready for embedding */
+  clutter_actor_realize (priv->stage);
+
+#ifdef HAVE_CLUTTER_GTK_X11
+  {
+    const XVisualInfo *xvinfo;
+    GdkVisual *visual;
+    GdkColormap *colormap;
+
+    /* We need to use the colormap from the Clutter visual */
+    xvinfo = clutter_x11_get_stage_visual (CLUTTER_STAGE (priv->stage));
+    visual = gdk_x11_screen_lookup_visual (gtk_widget_get_screen (widget),
+                                           xvinfo->visualid);
+    colormap = gdk_colormap_new (visual, FALSE);
+    gtk_widget_set_colormap (widget, colormap);
+  }
+#endif
+
   GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
 
   attributes.window_type = GDK_WINDOW_CHILD;
@@ -199,6 +214,9 @@ gtk_clutter_embed_realize (GtkWidget *widget)
                                   GDK_WINDOW_HWND (widget->window));
 #endif /* HAVE_CLUTTER_GTK_{X11,WIN32} */
 
+  if (GTK_WIDGET_VISIBLE (widget))
+    clutter_actor_show (priv->stage);
+
   clutter_actor_queue_redraw (CLUTTER_ACTOR (priv->stage));
 
   gtk_clutter_embed_send_configure (GTK_CLUTTER_EMBED (widget));
@@ -493,9 +511,6 @@ gtk_clutter_embed_init (GtkClutterEmbed *embed)
   /* we always create new stages rather than use the default */
   priv->stage = clutter_stage_new ();
 
-  /* we must realize the stage to get it ready for embedding */
-  clutter_actor_realize (priv->stage);
-
   /* intercept the queue-redraw signal of the stage to know when
    * Clutter-side requests a redraw; this way we can also request
    * a redraw GTK-side
@@ -504,21 +519,6 @@ gtk_clutter_embed_init (GtkClutterEmbed *embed)
     g_signal_connect (priv->stage,
                       "queue-redraw", G_CALLBACK (on_stage_queue_redraw),
                       embed);
-
-#ifdef HAVE_CLUTTER_GTK_X11
-  {
-    const XVisualInfo *xvinfo;
-    GdkVisual *visual;
-    GdkColormap *colormap;
-
-    /* We need to use the colormap from the Clutter visual */
-    xvinfo = clutter_x11_get_stage_visual (CLUTTER_STAGE (priv->stage));
-    visual = gdk_x11_screen_lookup_visual (gdk_screen_get_default (),
-                                           xvinfo->visualid);
-    colormap = gdk_colormap_new (visual, FALSE);
-    gtk_widget_set_colormap (GTK_WIDGET (embed), colormap);
-  }
-#endif
 }
 
 /**