[mutter/gbsneto/cleanup-x11-from-window-actor: 19/21] window-actor: Move window actor creation to MetaCompositor
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/cleanup-x11-from-window-actor: 19/21] window-actor: Move window actor creation to MetaCompositor
- Date: Thu, 3 Jan 2019 18:20:37 +0000 (UTC)
commit 133f1908446c25a063ce0e031635bfc50b1642aa
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Dec 22 12:21:34 2018 -0200
window-actor: Move window actor creation 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 window actor creation to under MetaCompositor and
stop violating (too badly) the resposabilities of each
component. This moves meta_window_actor_new() into
meta_compositor_add_window().
Also, move the remaining initialization code to the
GObject.constructed vfunc.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/368
src/compositor/compositor.c | 33 +++++++++++++-
src/compositor/meta-window-actor-private.h | 2 -
src/compositor/meta-window-actor.c | 71 ++++++------------------------
3 files changed, 46 insertions(+), 60 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index a378ed805..85bec8e3b 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -62,6 +62,8 @@
#include "clutter/clutter-mutter.h"
#include "clutter/x11/clutter-x11.h"
#include "compositor/meta-sync-ring.h"
+#include "compositor/meta-window-actor-x11.h"
+#include "compositor/meta-window-actor-wayland.h"
#include "compositor/meta-window-actor-private.h"
#include "compositor/meta-window-group-private.h"
#include "core/core.h"
@@ -660,11 +662,40 @@ void
meta_compositor_add_window (MetaCompositor *compositor,
MetaWindow *window)
{
+ MetaWindowActor *window_actor;
+ ClutterActor *window_group;
MetaDisplay *display = compositor->display;
+ GType window_actor_type;
meta_x11_error_trap_push (display->x11_display);
- meta_window_actor_new (window);
+ switch (window->client_type)
+ {
+ case META_WINDOW_CLIENT_TYPE_X11:
+ window_actor_type = META_TYPE_WINDOW_ACTOR_X11;
+ break;
+
+ case META_WINDOW_CLIENT_TYPE_WAYLAND:
+ window_actor_type = META_TYPE_WINDOW_ACTOR_WAYLAND;
+ break;
+ }
+
+ window_actor = g_object_new (window_actor_type,
+ "meta-window", window,
+ "visible", FALSE,
+ NULL);
+
+ 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-private.h b/src/compositor/meta-window-actor-private.h
index 62ae1dfed..24f2c6f59 100644
--- a/src/compositor/meta-window-actor-private.h
+++ b/src/compositor/meta-window-actor-private.h
@@ -29,8 +29,6 @@ struct _MetaWindowActorClass
void (*post_paint) (MetaWindowActor *actor);
};
-MetaWindowActor *meta_window_actor_new (MetaWindow *window);
-
void meta_window_actor_queue_destroy (MetaWindowActor *self);
void meta_window_actor_show (MetaWindowActor *self,
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index c1093f90c..2db65005b 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -425,6 +425,20 @@ meta_window_actor_constructed (GObject *object)
/* Start off with an empty shape region to maintain the invariant
* that it's always set */
priv->shape_region = cairo_region_create ();
+
+ meta_window_actor_sync_updates_frozen (self);
+
+ if (is_frozen (self))
+ priv->first_frame_state = INITIALLY_FROZEN;
+ else
+ priv->first_frame_state = DRAWING_FIRST_FRAME;
+
+ META_WINDOW_ACTOR_GET_CLASS (self)->post_init (self);
+
+ meta_window_actor_sync_actor_geometry (self, priv->window->placed);
+
+ /* Hang our compositor window state off the MetaWindow for fast retrieval */
+ meta_window_set_compositor_private (window, object);
}
static void
@@ -1225,63 +1239,6 @@ meta_window_actor_size_change (MetaWindowActor *self,
}
}
-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)
- {
- case META_WINDOW_CLIENT_TYPE_X11:
- window_actor_type = META_TYPE_WINDOW_ACTOR_X11;
- break;
-
- case META_WINDOW_CLIENT_TYPE_WAYLAND:
- window_actor_type = META_TYPE_WINDOW_ACTOR_WAYLAND;
- break;
- }
-
- self = g_object_new (window_actor_type,
- "meta-window", window,
- NULL);
- priv = meta_window_actor_get_instance_private (self);
-
- meta_window_actor_sync_updates_frozen (self);
-
- if (is_frozen (self))
- priv->first_frame_state = INITIALLY_FROZEN;
- else
- priv->first_frame_state = DRAWING_FIRST_FRAME;
-
- META_WINDOW_ACTOR_GET_CLASS (self)->post_init (self);
-
- meta_window_actor_sync_actor_geometry (self, priv->window->placed);
-
- /* 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;
-}
-
#if 0
/* Print out a region; useful for debugging */
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]