[mutter] context: Make the context own MetaWaylandCompositor
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] context: Make the context own MetaWaylandCompositor
- Date: Thu, 15 Jul 2021 12:40:56 +0000 (UTC)
commit 0330ce1f150f071620857a22a5550c48e179e1fe
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Wed Mar 3 22:00:05 2021 +0100
context: Make the context own MetaWaylandCompositor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
src/backends/meta-backend-private.h | 8 ----
src/backends/meta-backend-types.h | 2 -
src/backends/meta-backend.c | 30 ------------
src/backends/native/meta-backend-native.c | 5 --
src/backends/x11/nested/meta-backend-x11-nested.c | 4 --
src/core/meta-context-private.h | 3 ++
src/core/meta-context.c | 32 ++++++++-----
src/wayland/meta-wayland-actor-surface.c | 7 ++-
src/wayland/meta-wayland-cursor-surface.c | 3 +-
src/wayland/meta-wayland-presentation-time.c | 3 +-
src/wayland/meta-wayland-private.h | 2 +-
src/wayland/meta-wayland.c | 58 +++++++++++++----------
src/wayland/meta-wayland.h | 8 +---
13 files changed, 65 insertions(+), 100 deletions(-)
---
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index d2b210498d..81104e2d08 100644
--- a/src/backends/meta-backend-private.h
+++ b/src/backends/meta-backend-private.h
@@ -112,14 +112,6 @@ void meta_backend_destroy (MetaBackend *backend);
void meta_backend_prepare_shutdown (MetaBackend *backend);
-#ifdef HAVE_WAYLAND
-MetaWaylandCompositor * meta_backend_get_wayland_compositor (MetaBackend *backend);
-
-void meta_backend_init_wayland_display (MetaBackend *backend);
-
-void meta_backend_init_wayland (MetaBackend *backend);
-#endif
-
ClutterBackend * meta_backend_get_clutter_backend (MetaBackend *backend);
ClutterSeat * meta_backend_get_default_seat (MetaBackend *bakcend);
diff --git a/src/backends/meta-backend-types.h b/src/backends/meta-backend-types.h
index a959f6db29..c5e46d87a1 100644
--- a/src/backends/meta-backend-types.h
+++ b/src/backends/meta-backend-types.h
@@ -57,8 +57,6 @@ typedef struct _MetaScreenCast MetaScreenCast;
typedef struct _MetaScreenCastSession MetaScreenCastSession;
typedef struct _MetaScreenCastStream MetaScreenCastStream;
-typedef struct _MetaWaylandCompositor MetaWaylandCompositor;
-
typedef struct _MetaVirtualMonitor MetaVirtualMonitor;
typedef struct _MetaVirtualMonitorInfo MetaVirtualMonitorInfo;
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 5b785ab404..d4cd5d10fc 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -154,10 +154,6 @@ struct _MetaBackendPrivate
MetaRemoteDesktop *remote_desktop;
#endif
-#ifdef HAVE_WAYLAND
- MetaWaylandCompositor *wayland_compositor;
-#endif
-
#ifdef HAVE_PROFILER
MetaProfiler *profiler;
#endif
@@ -960,32 +956,6 @@ system_bus_gotten_cb (GObject *object,
NULL);
}
-#ifdef HAVE_WAYLAND
-MetaWaylandCompositor *
-meta_backend_get_wayland_compositor (MetaBackend *backend)
-{
- MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
-
- return priv->wayland_compositor;
-}
-
-void
-meta_backend_init_wayland_display (MetaBackend *backend)
-{
- MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
-
- priv->wayland_compositor = meta_wayland_compositor_new (backend);
-}
-
-void
-meta_backend_init_wayland (MetaBackend *backend)
-{
- MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
-
- meta_wayland_compositor_setup (priv->wayland_compositor);
-}
-#endif
-
/* Mutter is responsible for pulling events off the X queue, so Clutter
* doesn't need (and shouldn't) run its normal event source which polls
* the X fd, but we do have to deal with dispatching events that accumulate
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index d5dd148d38..81d9629d05 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -577,11 +577,6 @@ meta_backend_native_initable_init (GInitable *initable,
}
native->device_pool = meta_device_pool_new (native->launcher);
-
-#ifdef HAVE_WAYLAND
- meta_backend_init_wayland_display (META_BACKEND (native));
-#endif
-
native->udev = meta_udev_new (native);
kms_flags = META_KMS_FLAG_NONE;
diff --git a/src/backends/x11/nested/meta-backend-x11-nested.c
b/src/backends/x11/nested/meta-backend-x11-nested.c
index bf6296dbf8..041b42860b 100644
--- a/src/backends/x11/nested/meta-backend-x11-nested.c
+++ b/src/backends/x11/nested/meta-backend-x11-nested.c
@@ -250,10 +250,6 @@ meta_backend_x11_nested_initable_init (GInitable *initable,
GCancellable *cancellable,
GError **error)
{
-#ifdef HAVE_WAYLAND
- meta_backend_init_wayland_display (META_BACKEND (initable));
-#endif
-
return initable_parent_iface->init (initable, cancellable, error);
}
diff --git a/src/core/meta-context-private.h b/src/core/meta-context-private.h
index ca38ddddbb..70a5245ec6 100644
--- a/src/core/meta-context-private.h
+++ b/src/core/meta-context-private.h
@@ -23,6 +23,7 @@
#include "meta/meta-backend.h"
#include "meta/meta-context.h"
+#include "wayland/meta-wayland-types.h"
struct _MetaContextClass
{
@@ -44,4 +45,6 @@ struct _MetaContextClass
void (* notify_ready) (MetaContext *context);
};
+MetaWaylandCompositor * meta_context_get_wayland_compositor (MetaContext *context);
+
#endif /* META_CONTEXT_PRIVATE_H */
diff --git a/src/core/meta-context.c b/src/core/meta-context.c
index 47b540afcf..f2cdb00476 100644
--- a/src/core/meta-context.c
+++ b/src/core/meta-context.c
@@ -56,6 +56,9 @@ typedef struct _MetaContextPrivate
MetaBackend *backend;
MetaDisplay *display;
+#ifdef HAVE_WAYLAND
+ MetaWaylandCompositor *wayland_compositor;
+#endif
GMainLoop *main_loop;
GError *termination_error;
@@ -142,6 +145,16 @@ meta_context_get_display (MetaContext *context)
return priv->display;
}
+#ifdef HAVE_WAYLAND
+MetaWaylandCompositor *
+meta_context_get_wayland_compositor (MetaContext *context)
+{
+ MetaContextPrivate *priv = meta_context_get_instance_private (context);
+
+ return priv->wayland_compositor;
+}
+#endif
+
MetaCompositorType
meta_context_get_compositor_type (MetaContext *context)
{
@@ -304,6 +317,10 @@ meta_context_setup (MetaContext *context,
init_introspection (context);
+#ifdef HAVE_WAYLAND
+ priv->wayland_compositor = meta_wayland_compositor_new (context);
+#endif
+
return META_CONTEXT_GET_CLASS (context)->setup (context, error);
}
@@ -318,7 +335,7 @@ meta_context_start (MetaContext *context,
#ifdef HAVE_WAYLAND
if (meta_context_get_compositor_type (context) ==
META_COMPOSITOR_TYPE_WAYLAND)
- meta_backend_init_wayland (meta_get_backend ());
+ meta_wayland_compositor_setup (priv->wayland_compositor);
#endif
priv->display = meta_display_new (context, error);
@@ -420,18 +437,13 @@ meta_context_finalize (GObject *object)
{
MetaContext *context = META_CONTEXT (object);
MetaContextPrivate *priv = meta_context_get_instance_private (context);
-#ifdef HAVE_WAYLAND
- MetaWaylandCompositor *compositor;
- MetaCompositorType compositor_type;
-#endif
if (priv->backend)
meta_backend_prepare_shutdown (priv->backend);
#ifdef HAVE_WAYLAND
- compositor = meta_wayland_compositor_get_default ();
- if (compositor)
- meta_wayland_compositor_prepare_shutdown (compositor);
+ if (priv->wayland_compositor)
+ meta_wayland_compositor_prepare_shutdown (priv->wayland_compositor);
#endif
if (priv->display)
@@ -439,9 +451,7 @@ meta_context_finalize (GObject *object)
g_clear_object (&priv->display);
#ifdef HAVE_WAYLAND
- compositor_type = meta_context_get_compositor_type (context);
- if (compositor_type == META_COMPOSITOR_TYPE_WAYLAND)
- meta_wayland_finalize ();
+ g_clear_object (&priv->wayland_compositor);
#endif
g_clear_pointer (&priv->backend, meta_backend_destroy);
diff --git a/src/wayland/meta-wayland-actor-surface.c b/src/wayland/meta-wayland-actor-surface.c
index 797795f861..bdebe6b2b4 100644
--- a/src/wayland/meta-wayland-actor-surface.c
+++ b/src/wayland/meta-wayland-actor-surface.c
@@ -302,12 +302,11 @@ meta_wayland_actor_surface_apply_state (MetaWaylandSurfaceRole *surface_role,
if (!wl_list_empty (&pending->frame_callback_list) &&
priv->actor &&
+ clutter_actor_is_mapped (CLUTTER_ACTOR (priv->actor)) &&
!meta_surface_actor_is_obscured (priv->actor))
{
- MetaWaylandSurface *surface =
- meta_wayland_surface_role_get_surface (surface_role);
- MetaBackend *backend = surface->compositor->backend;
- ClutterActor *stage = meta_backend_get_stage (backend);
+ ClutterActor *stage =
+ clutter_actor_get_stage (CLUTTER_ACTOR (priv->actor));
clutter_stage_schedule_update (CLUTTER_STAGE (stage));
}
diff --git a/src/wayland/meta-wayland-cursor-surface.c b/src/wayland/meta-wayland-cursor-surface.c
index bece48b04a..d1f521818a 100644
--- a/src/wayland/meta-wayland-cursor-surface.c
+++ b/src/wayland/meta-wayland-cursor-surface.c
@@ -342,8 +342,9 @@ on_cursor_painted (MetaCursorRenderer *renderer,
meta_wayland_cursor_surface_get_instance_private (cursor_surface);
guint32 time = (guint32) (g_get_monotonic_time () / 1000);
MetaBackend *backend = meta_get_backend ();
+ MetaContext *context = meta_backend_get_context (backend);
MetaWaylandCompositor *compositor =
- meta_backend_get_wayland_compositor (backend);
+ meta_context_get_wayland_compositor (context);
if (displayed_sprite != META_CURSOR_SPRITE (priv->cursor_sprite))
return;
diff --git a/src/wayland/meta-wayland-presentation-time.c b/src/wayland/meta-wayland-presentation-time.c
index 29650698cf..b0d8cf81c6 100644
--- a/src/wayland/meta-wayland-presentation-time.c
+++ b/src/wayland/meta-wayland-presentation-time.c
@@ -212,7 +212,8 @@ on_monitors_changed (MetaMonitorManager *manager,
void
meta_wayland_init_presentation_time (MetaWaylandCompositor *compositor)
{
- MetaBackend *backend = compositor->backend;
+ MetaContext *context = compositor->context;
+ MetaBackend *backend = meta_context_get_backend (context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
ClutterActor *stage = meta_backend_get_stage (backend);
diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h
index 2782789206..5272b530f1 100644
--- a/src/wayland/meta-wayland-private.h
+++ b/src/wayland/meta-wayland-private.h
@@ -82,7 +82,7 @@ struct _MetaWaylandCompositor
{
GObject parent;
- MetaBackend *backend;
+ MetaContext *context;
struct wl_display *wayland_display;
char *display_name;
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 4431fcc19e..14217ca941 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -60,10 +60,12 @@ MetaWaylandCompositor *
meta_wayland_compositor_get_default (void)
{
MetaBackend *backend;
+ MetaContext *context;
MetaWaylandCompositor *wayland_compositor;
backend = meta_get_backend ();
- wayland_compositor = meta_backend_get_wayland_compositor (backend);
+ context = meta_backend_get_context (backend);
+ wayland_compositor = meta_context_get_wayland_compositor (context);
g_assert (wayland_compositor);
return wayland_compositor;
@@ -407,6 +409,28 @@ meta_wayland_log_func (const char *fmt,
g_free (str);
}
+void
+meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor)
+{
+ meta_xwayland_shutdown (&compositor->xwayland_manager);
+
+ if (compositor->wayland_display)
+ wl_display_destroy_clients (compositor->wayland_display);
+}
+
+static void
+meta_wayland_compositor_finalize (GObject *object)
+{
+ MetaWaylandCompositor *compositor = META_WAYLAND_COMPOSITOR (object);
+
+ g_clear_pointer (&compositor->seat, meta_wayland_seat_free);
+
+ g_clear_pointer (&compositor->display_name, g_free);
+ g_clear_pointer (&compositor->wayland_display, wl_display_destroy);
+
+ G_OBJECT_CLASS (meta_wayland_compositor_parent_class)->finalize (object);
+}
+
static void
meta_wayland_compositor_init (MetaWaylandCompositor *compositor)
{
@@ -422,6 +446,9 @@ meta_wayland_compositor_init (MetaWaylandCompositor *compositor)
static void
meta_wayland_compositor_class_init (MetaWaylandCompositorClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = meta_wayland_compositor_finalize;
}
static bool
@@ -455,12 +482,12 @@ meta_wayland_get_xwayland_auth_file (MetaWaylandCompositor *compositor)
}
MetaWaylandCompositor *
-meta_wayland_compositor_new (MetaBackend *backend)
+meta_wayland_compositor_new (MetaContext *context)
{
MetaWaylandCompositor *compositor;
compositor = g_object_new (META_TYPE_WAYLAND_COMPOSITOR, NULL);
- compositor->backend = backend;
+ compositor->context = context;
return compositor;
}
@@ -498,7 +525,8 @@ meta_wayland_init_egl (MetaWaylandCompositor *compositor)
void
meta_wayland_compositor_setup (MetaWaylandCompositor *compositor)
{
- ClutterActor *stage = meta_backend_get_stage (compositor->backend);
+ MetaBackend *backend = meta_context_get_backend (compositor->context);
+ ClutterActor *stage = meta_backend_get_stage (backend);
GSource *wayland_event_source;
wayland_event_source = wayland_event_source_new (compositor->wayland_display);
@@ -616,28 +644,6 @@ meta_wayland_get_private_xwayland_display_name (MetaWaylandCompositor *composito
return compositor->xwayland_manager.private_connection.name;
}
-void
-meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor)
-{
- meta_xwayland_shutdown (&compositor->xwayland_manager);
-
- if (compositor->wayland_display)
- wl_display_destroy_clients (compositor->wayland_display);
-}
-
-void
-meta_wayland_finalize (void)
-{
- MetaWaylandCompositor *compositor;
-
- compositor = meta_wayland_compositor_get_default ();
-
- g_clear_pointer (&compositor->seat, meta_wayland_seat_free);
-
- g_clear_pointer (&compositor->display_name, g_free);
- g_clear_pointer (&compositor->wayland_display, wl_display_destroy);
-}
-
void
meta_wayland_compositor_restore_shortcuts (MetaWaylandCompositor *compositor,
ClutterInputDevice *source)
diff --git a/src/wayland/meta-wayland.h b/src/wayland/meta-wayland.h
index 84e4ccb034..e28090f105 100644
--- a/src/wayland/meta-wayland.h
+++ b/src/wayland/meta-wayland.h
@@ -32,13 +32,7 @@
META_EXPORT_TEST
void meta_wayland_override_display_name (const char *display_name);
-void meta_wayland_pre_clutter_init (void);
-
-void meta_wayland_init (void);
-
-void meta_wayland_finalize (void);
-
-MetaWaylandCompositor * meta_wayland_compositor_new (MetaBackend *backend);
+MetaWaylandCompositor * meta_wayland_compositor_new (MetaContext *context);
void meta_wayland_compositor_setup (MetaWaylandCompositor *compositor);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]