[mutter/gbsneto/cleanup-x11-from-window-actor: 7/7] window-actor: Move some code to MetaCompositor



commit 6cdfbbd7e59064db9a3bcebd423d132f807867a2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sat Dec 22 12:21:34 2018 -0200

    window-actor: Move some code to MetaCompositor
    
    MetaWindowActor breaks layering isolation by accessing
    and injecting itself into compositor->windows. This is
    a bad practice, and effecticely makes returning the
    new actor useless, since we doesn't even use the return
    value.
    
    Move this code to under MetaCompositor and stop violating
    (too badly) the resposabilities of each component.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/368

 src/compositor/compositor.c        | 16 +++++++++++++++-
 src/compositor/meta-window-actor.c | 15 ---------------
 2 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index a378ed805..3d9bd895a 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -660,11 +660,25 @@ void
 meta_compositor_add_window (MetaCompositor    *compositor,
                             MetaWindow        *window)
 {
+  MetaWindowActor *window_actor;
+  ClutterActor *window_group;
   MetaDisplay *display = compositor->display;
 
   meta_x11_error_trap_push (display->x11_display);
 
-  meta_window_actor_new (window);
+  window_actor = meta_window_actor_new (window);
+
+  if (window->layer == META_LAYER_OVERRIDE_REDIRECT)
+    window_group = compositor->top_window_group;
+  else
+    window_group = compositor->window_group;
+
+  clutter_actor_add_child (window_group, CLUTTER_ACTOR (window_actor));
+
+  /* Initial position in the stack is arbitrary; stacking will be synced
+   * before we first paint.
+   */
+  compositor->windows = g_list_append (compositor->windows, window_actor);
   sync_actor_stacking (compositor);
 
   meta_x11_error_trap_pop (display->x11_display);
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index baa025a75..ad7f41579 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -1236,10 +1236,7 @@ MetaWindowActor *
 meta_window_actor_new (MetaWindow *window)
 {
   MetaWindowActorPrivate *priv;
-  MetaDisplay *display = meta_window_get_display (window);
-  MetaCompositor *compositor = display->compositor;
   MetaWindowActor        *self;
-  ClutterActor           *window_group;
   GType window_actor_type;
 
   switch (window->client_type)
@@ -1272,20 +1269,8 @@ meta_window_actor_new (MetaWindow *window)
   /* Hang our compositor window state off the MetaWindow for fast retrieval */
   meta_window_set_compositor_private (window, G_OBJECT (self));
 
-  if (window->layer == META_LAYER_OVERRIDE_REDIRECT)
-    window_group = compositor->top_window_group;
-  else
-    window_group = compositor->window_group;
-
-  clutter_actor_add_child (window_group, CLUTTER_ACTOR (self));
-
   clutter_actor_hide (CLUTTER_ACTOR (self));
 
-  /* Initial position in the stack is arbitrary; stacking will be synced
-   * before we first paint.
-   */
-  compositor->windows = g_list_append (compositor->windows, self);
-
   return self;
 }
 


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