diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index c8b3e303d..d60865910 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -58,7 +58,6 @@ #include "backends/meta-dnd-private.h" #include "clutter/clutter-mutter.h" -#include "compositor/meta-compositor-x11.h" #include "compositor/meta-window-actor-x11.h" #include "compositor/meta-window-actor-wayland.h" #include "compositor/meta-window-actor-private.h" @@ -80,10 +79,20 @@ #include "x11/meta-x11-display-private.h" #ifdef HAVE_WAYLAND -#include "compositor/meta-compositor-server.h" #include "wayland/meta-wayland-private.h" #endif +enum +{ + PROP_0, + + PROP_DISPLAY, + + N_PROPS +}; + +static GParamSpec *obj_props[N_PROPS] = { NULL, }; + typedef struct _MetaCompositorPrivate { GObject parent; @@ -1140,28 +1149,44 @@ on_shadow_factory_changed (MetaShadowFactory *factory, meta_window_actor_invalidate_shadow (l->data); } -/** - * meta_compositor_new: (skip) - * @display: - * - */ -MetaCompositor * -meta_compositor_new (MetaDisplay *display) +static void +meta_compositor_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - MetaCompositor *compositor; - MetaCompositorPrivate *priv; + MetaCompositor *compositor = META_COMPOSITOR (object); + MetaCompositorPrivate *priv = + meta_compositor_get_instance_private (compositor); -#ifdef HAVE_WAYLAND - if (meta_is_wayland_compositor ()) - compositor = g_object_new (META_TYPE_COMPOSITOR_SERVER, NULL); - else -#endif - compositor = g_object_new (META_TYPE_COMPOSITOR_X11, NULL); + switch (prop_id) + { + case PROP_DISPLAY: + priv->display = g_value_get_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} - priv = meta_compositor_get_instance_private (compositor); - priv->display = display; +static void +meta_compositor_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + MetaCompositor *compositor = META_COMPOSITOR (object); + MetaCompositorPrivate *priv = + meta_compositor_get_instance_private (compositor); - return compositor; + switch (prop_id) + { + case PROP_DISPLAY: + g_value_set_object (value, priv->display); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } } static void @@ -1222,11 +1247,23 @@ meta_compositor_class_init (MetaCompositorClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->set_property = meta_compositor_set_property; + object_class->get_property = meta_compositor_get_property; object_class->dispose = meta_compositor_dispose; klass->remove_window = meta_compositor_real_remove_window; klass->pre_paint = meta_compositor_real_pre_paint; klass->post_paint = meta_compositor_real_post_paint; + + obj_props[PROP_DISPLAY] = + g_param_spec_object ("display", + "display", + "MetaDisplay", + META_TYPE_DISPLAY, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, N_PROPS, obj_props); } /** diff --git a/src/compositor/meta-compositor-server.c b/src/compositor/meta-compositor-server.c index 206586c06..928501f8a 100644 --- a/src/compositor/meta-compositor-server.c +++ b/src/compositor/meta-compositor-server.c @@ -39,6 +39,14 @@ meta_compositor_server_unmanage (MetaCompositor *compositor) { } +MetaCompositorServer * +meta_compositor_server_new (MetaDisplay *display) +{ + return g_object_new (META_TYPE_COMPOSITOR_SERVER, + "display", display, + NULL); +} + static void meta_compositor_server_init (MetaCompositorServer *compositor_server) { diff --git a/src/compositor/meta-compositor-server.h b/src/compositor/meta-compositor-server.h index b16971ae3..8bff05e7b 100644 --- a/src/compositor/meta-compositor-server.h +++ b/src/compositor/meta-compositor-server.h @@ -27,4 +27,6 @@ G_DECLARE_FINAL_TYPE (MetaCompositorServer, meta_compositor_server, META, COMPOSITOR_SERVER, MetaCompositor) +MetaCompositorServer * meta_compositor_server_new (MetaDisplay *display); + #endif /* META_COMPOSITOR_SERVER_H */ diff --git a/src/compositor/meta-compositor-x11.c b/src/compositor/meta-compositor-x11.c index 15534ccd3..15be1169c 100644 --- a/src/compositor/meta-compositor-x11.c +++ b/src/compositor/meta-compositor-x11.c @@ -322,6 +322,14 @@ meta_compositor_x11_get_output_xwindow (MetaCompositorX11 *compositor_x11) return compositor_x11->output; } +MetaCompositorX11 * +meta_compositor_x11_new (MetaDisplay *display) +{ + return g_object_new (META_TYPE_COMPOSITOR_X11, + "display", display, + NULL); +} + static void meta_compositor_x11_dispose (GObject *object) { diff --git a/src/compositor/meta-compositor-x11.h b/src/compositor/meta-compositor-x11.h index f577f73e0..7165493cd 100644 --- a/src/compositor/meta-compositor-x11.h +++ b/src/compositor/meta-compositor-x11.h @@ -27,6 +27,8 @@ G_DECLARE_FINAL_TYPE (MetaCompositorX11, meta_compositor_x11, META, COMPOSITOR_X11, MetaCompositor) +MetaCompositorX11 * meta_compositor_x11_new (MetaDisplay *display); + void meta_compositor_x11_process_xevent (MetaCompositorX11 *compositor_x11, XEvent *xevent, MetaWindow *window); diff --git a/src/core/display.c b/src/core/display.c index 3d1e33429..71b0fb49d 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -50,6 +50,7 @@ #include "backends/x11/cm/meta-backend-x11-cm.h" #include "clutter/x11/clutter-x11.h" #include "compositor/compositor-private.h" +#include "compositor/meta-compositor-x11.h" #include "core/bell.h" #include "core/boxes-private.h" #include "core/display-private.h" @@ -76,6 +77,7 @@ #include "x11/xprops.h" #ifdef HAVE_WAYLAND +#include "compositor/meta-compositor-server.h" #include "wayland/meta-xwayland-private.h" #include "wayland/meta-wayland-tablet-seat.h" #include "wayland/meta-wayland-tablet-pad.h" @@ -538,6 +540,16 @@ meta_display_remove_pending_pings_for_window (MetaDisplay *display, g_slist_free (dead); } +static MetaCompositor * +create_compositor (MetaDisplay *display) +{ +#ifdef HAVE_WAYLAND + if (meta_is_wayland_compositor ()) + return META_COMPOSITOR (meta_compositor_server_new (display)); + else +#endif + return META_COMPOSITOR (meta_compositor_x11_new (display)); +} static void enable_compositor (MetaDisplay *display) @@ -567,7 +579,7 @@ enable_compositor (MetaDisplay *display) } if (!display->compositor) - display->compositor = meta_compositor_new (display); + display->compositor = create_compositor (display); meta_compositor_manage (display->compositor); } diff --git a/src/meta/compositor.h b/src/meta/compositor.h index 1a028b90e..1ccae70d7 100644 --- a/src/meta/compositor.h +++ b/src/meta/compositor.h @@ -66,9 +66,6 @@ typedef enum META_SIZE_CHANGE_UNFULLSCREEN, } MetaSizeChange; -META_EXPORT -MetaCompositor *meta_compositor_new (MetaDisplay *display); - META_EXPORT void meta_compositor_destroy (MetaCompositor *compositor);