[mutter/wip/surface-content: 12/14] xwayland: Update the surface actor for the window on set_window_id



commit a318198ab47d7aa5d3b78a6c7e7176f490827fb6
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Dec 9 13:47:55 2013 -0500

    xwayland: Update the surface actor for the window on set_window_id
    
    We need to do this for XWayland windows, since we only get the event
    telling us they're an XWayland window after the compositor knows about
    the window.

 src/compositor/meta-window-actor.c |   60 ++++++++++++++++++++++++++---------
 1 files changed, 44 insertions(+), 16 deletions(-)
---
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index fe09ace..10df90d 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -306,29 +306,60 @@ meta_window_actor_thaw (MetaWindowActor *self)
 }
 
 static void
-meta_window_actor_constructed (GObject *object)
+set_surface_actor (MetaWindowActor  *self,
+                   MetaSurfaceActor *surface)
 {
-  MetaWindowActor        *self     = META_WINDOW_ACTOR (object);
-  MetaWindowActorPrivate *priv     = self->priv;
-  MetaWindow             *window   = priv->window;
+  MetaWindowActorPrivate *priv = self->priv;
 
-  priv->screen = window->screen;
+  if (priv->surface)
+    {
+      g_object_unref (priv->surface);
+      clutter_actor_remove_child (CLUTTER_ACTOR (self), CLUTTER_ACTOR (priv->surface));
+    }
 
-  if (!priv->surface)
+  priv->surface = surface;
+
+  if (priv->surface)
     {
-      if (window->surface)
-        priv->surface = window->surface->surface_actor;
-      else
-        priv->surface = meta_surface_actor_x11_new (window);
       g_object_ref_sink (priv->surface);
-
       clutter_actor_add_child (CLUTTER_ACTOR (self), CLUTTER_ACTOR (priv->surface));
 
       g_signal_connect_object (priv->surface, "allocation-changed",
                                G_CALLBACK (surface_allocation_changed_notify), self, 0);
-      meta_window_actor_update_shape (self);
     }
 
+  meta_window_actor_update_shape (self);
+}
+
+static void
+meta_window_actor_sync_surface_actor (MetaWindowActor *self)
+{
+  MetaWindowActorPrivate *priv = self->priv;
+  MetaWindow *window = priv->window;
+
+  MetaSurfaceActor *surface = NULL;
+
+  if (window)
+    {
+      if (window->surface)
+        surface = window->surface->surface_actor;
+      else
+        surface = meta_surface_actor_x11_new (window);
+    }
+
+  set_surface_actor (self, surface);
+}
+
+static void
+meta_window_actor_constructed (GObject *object)
+{
+  MetaWindowActor        *self     = META_WINDOW_ACTOR (object);
+  MetaWindowActorPrivate *priv     = self->priv;
+  MetaWindow             *window   = priv->window;
+
+  priv->screen = window->screen;
+
+  meta_window_actor_sync_surface_actor (self);
   meta_window_actor_update_opacity (self);
 
   /* Start off with an empty shape region to maintain the invariant
@@ -370,10 +401,7 @@ meta_window_actor_dispose (GObject *object)
 
   g_clear_object (&priv->window);
 
-  /*
-   * Release the extra reference we took on the actor.
-   */
-  g_clear_object (&priv->surface);
+  meta_window_actor_sync_surface_actor (self);
 
   G_OBJECT_CLASS (meta_window_actor_parent_class)->dispose (object);
 }


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