mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
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
This commit is contained in:
parent
7952808469
commit
54febd1419
@ -62,6 +62,8 @@
|
|||||||
#include "clutter/clutter-mutter.h"
|
#include "clutter/clutter-mutter.h"
|
||||||
#include "clutter/x11/clutter-x11.h"
|
#include "clutter/x11/clutter-x11.h"
|
||||||
#include "compositor/meta-sync-ring.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-actor-private.h"
|
||||||
#include "compositor/meta-window-group-private.h"
|
#include "compositor/meta-window-group-private.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
@ -660,11 +662,39 @@ void
|
|||||||
meta_compositor_add_window (MetaCompositor *compositor,
|
meta_compositor_add_window (MetaCompositor *compositor,
|
||||||
MetaWindow *window)
|
MetaWindow *window)
|
||||||
{
|
{
|
||||||
|
MetaWindowActor *window_actor;
|
||||||
|
ClutterActor *window_group;
|
||||||
MetaDisplay *display = compositor->display;
|
MetaDisplay *display = compositor->display;
|
||||||
|
GType window_actor_type;
|
||||||
|
|
||||||
meta_x11_error_trap_push (display->x11_display);
|
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,
|
||||||
|
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);
|
sync_actor_stacking (compositor);
|
||||||
|
|
||||||
meta_x11_error_trap_pop (display->x11_display);
|
meta_x11_error_trap_pop (display->x11_display);
|
||||||
|
@ -30,8 +30,6 @@ struct _MetaWindowActorClass
|
|||||||
void (*queue_destroy) (MetaWindowActor *actor);
|
void (*queue_destroy) (MetaWindowActor *actor);
|
||||||
};
|
};
|
||||||
|
|
||||||
MetaWindowActor *meta_window_actor_new (MetaWindow *window);
|
|
||||||
|
|
||||||
void meta_window_actor_queue_destroy (MetaWindowActor *self);
|
void meta_window_actor_queue_destroy (MetaWindowActor *self);
|
||||||
|
|
||||||
void meta_window_actor_show (MetaWindowActor *self,
|
void meta_window_actor_show (MetaWindowActor *self,
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
#include "compositor/meta-surface-actor.h"
|
#include "compositor/meta-surface-actor.h"
|
||||||
#include "compositor/meta-texture-rectangle.h"
|
#include "compositor/meta-texture-rectangle.h"
|
||||||
#include "compositor/meta-window-actor-private.h"
|
#include "compositor/meta-window-actor-private.h"
|
||||||
#include "compositor/meta-window-actor-wayland.h"
|
|
||||||
#include "compositor/meta-window-actor-x11.h"
|
|
||||||
#include "compositor/region-utils.h"
|
#include "compositor/region-utils.h"
|
||||||
#include "meta/meta-enum-types.h"
|
#include "meta/meta-enum-types.h"
|
||||||
#include "meta/meta-shadow-factory.h"
|
#include "meta/meta-shadow-factory.h"
|
||||||
@ -425,6 +423,20 @@ meta_window_actor_constructed (GObject *object)
|
|||||||
/* Start off with an empty shape region to maintain the invariant
|
/* Start off with an empty shape region to maintain the invariant
|
||||||
* that it's always set */
|
* that it's always set */
|
||||||
priv->shape_region = cairo_region_create ();
|
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
|
static void
|
||||||
@ -1227,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
|
#if 0
|
||||||
/* Print out a region; useful for debugging */
|
/* Print out a region; useful for debugging */
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user