[mutter] xwayland: Make setup/teardown a bit more symmetrical
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] xwayland: Make setup/teardown a bit more symmetrical
- Date: Tue, 26 Oct 2021 16:23:57 +0000 (UTC)
commit b4fe1fdd95d52e8625c66ded1ec7162371dcf32b
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Tue Mar 23 16:47:45 2021 +0100
xwayland: Make setup/teardown a bit more symmetrical
We setup Xwayland in an early phase of the X11 display, before we had a
MetaX11Display, and teared down in a couple of places happening when
tearing down the Xwayland integration if the X server died or
terminated. It was a bit hard to follow what happened and when it
happened. Attempt to clean this up a bit, with things being structured
as follows:
* Early during X11 display connection setup, only setup the rudimentary
X11 hooks, being the libX11 error callbacks, and adding the local
user to XHost.
* Move "initialize Xwayland component" code to a new
'x11-display-setup' signal handler. Things setup here are cleaned up
in the 'x11-display-closing' handler.
* Connect to 'x11-display-setup' and 'x11-display-closing' up front,
and stay connected to these two.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
src/core/display.c | 4 +++
src/wayland/meta-wayland.c | 7 +++++
src/wayland/meta-wayland.h | 3 ++
src/wayland/meta-xwayland-private.h | 8 ++++--
src/wayland/meta-xwayland.c | 57 +++++++++++++++++++++++--------------
src/x11/meta-x11-display.c | 8 +++++-
6 files changed, 62 insertions(+), 25 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index fcfc13fe4f..37b8f04caa 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -889,8 +889,12 @@ meta_display_new (MetaContext *context,
#ifdef HAVE_WAYLAND
if (meta_is_wayland_compositor ())
{
+ MetaWaylandCompositor *wayland_compositor =
+ meta_wayland_compositor_get_default ();
MetaX11DisplayPolicy x11_display_policy;
+ meta_wayland_compositor_init_display (wayland_compositor, display);
+
x11_display_policy = meta_context_get_x11_display_policy (context);
if (x11_display_policy == META_X11_DISPLAY_POLICY_MANDATORY)
{
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index ceb2afed35..3381a497e6 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -400,6 +400,13 @@ set_gnome_env (const char *name,
}
}
+void
+meta_wayland_compositor_init_display (MetaWaylandCompositor *compositor,
+ MetaDisplay *display)
+{
+ meta_xwayland_init_display (&compositor->xwayland_manager, display);
+}
+
static void meta_wayland_log_func (const char *, va_list) G_GNUC_PRINTF (1, 0);
static void
diff --git a/src/wayland/meta-wayland.h b/src/wayland/meta-wayland.h
index 387e98b522..bee2ef4455 100644
--- a/src/wayland/meta-wayland.h
+++ b/src/wayland/meta-wayland.h
@@ -36,6 +36,9 @@ MetaWaylandCompositor * meta_wayland_compositor_new (MetaContext *co
void meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor);
+void meta_wayland_compositor_init_display (MetaWaylandCompositor *compositor,
+ MetaDisplay *display);
+
META_EXPORT_TEST
MetaWaylandCompositor *meta_wayland_compositor_get_default (void);
diff --git a/src/wayland/meta-xwayland-private.h b/src/wayland/meta-xwayland-private.h
index 51fba035eb..1efa948159 100644
--- a/src/wayland/meta-xwayland-private.h
+++ b/src/wayland/meta-xwayland-private.h
@@ -31,8 +31,12 @@ meta_xwayland_init (MetaXWaylandManager *manager,
GError **error);
void
-meta_xwayland_complete_init (MetaDisplay *display,
- Display *xdisplay);
+meta_xwayland_init_display (MetaXWaylandManager *manager,
+ MetaDisplay *display);
+
+void
+meta_xwayland_setup_xdisplay (MetaXWaylandManager *manager,
+ Display *xdisplay);
void
meta_xwayland_shutdown (MetaXWaylandManager *manager);
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 8789cbdd84..84db7bc668 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -1137,9 +1137,6 @@ meta_xwayland_stop_xserver (MetaXWaylandManager *manager)
{
if (manager->proc)
g_subprocess_send_signal (manager->proc, SIGTERM);
- g_signal_handlers_disconnect_by_func (meta_get_display (),
- window_created_cb,
- manager);
g_clear_object (&manager->xserver_died_cancellable);
g_clear_object (&manager->proc);
}
@@ -1230,6 +1227,9 @@ on_x11_display_closing (MetaDisplay *display,
g_signal_handlers_disconnect_by_func (display,
on_x11_display_closing,
manager);
+ g_signal_handlers_disconnect_by_func (display,
+ window_created_cb,
+ manager);
}
static void
@@ -1254,15 +1254,41 @@ meta_xwayland_init_xrandr (MetaXWaylandManager *manager,
meta_xwayland_set_primary_output (xdisplay);
}
-/* To be called right after connecting */
-void
-meta_xwayland_complete_init (MetaDisplay *display,
- Display *xdisplay)
+static void
+on_x11_display_setup (MetaDisplay *display,
+ MetaXWaylandManager *manager)
{
- MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
- MetaXWaylandManager *manager = &compositor->xwayland_manager;
+ MetaX11Display *x11_display = meta_display_get_x11_display (display);
+ MetaContext *context = meta_display_get_context (display);
+ Display *xdisplay = meta_x11_display_get_xdisplay (x11_display);
MetaX11DisplayPolicy x11_display_policy;
+ meta_xwayland_init_dnd (xdisplay);
+ meta_xwayland_init_xrandr (manager, xdisplay);
+ meta_xwayland_stop_xserver_timeout (manager);
+
+ x11_display_policy = meta_context_get_x11_display_policy (context);
+ if (x11_display_policy == META_X11_DISPLAY_POLICY_ON_DEMAND)
+ {
+ g_signal_connect (display, "window-created",
+ G_CALLBACK (window_created_cb), manager);
+ }
+}
+
+void
+meta_xwayland_init_display (MetaXWaylandManager *manager,
+ MetaDisplay *display)
+{
+ g_signal_connect (display, "x11-display-setup",
+ G_CALLBACK (on_x11_display_setup), manager);
+ g_signal_connect (display, "x11-display-closing",
+ G_CALLBACK (on_x11_display_closing), manager);
+}
+
+void
+meta_xwayland_setup_xdisplay (MetaXWaylandManager *manager,
+ Display *xdisplay)
+{
/* We install an X IO error handler in addition to the child watch,
because after Xlib connects our child watch may not be called soon
enough, and therefore we won't crash when X exits (and most important
@@ -1273,20 +1299,7 @@ meta_xwayland_complete_init (MetaDisplay *display,
XSetIOErrorExitHandler (xdisplay, x_io_error_exit, manager);
#endif
- g_signal_connect (display, "x11-display-closing",
- G_CALLBACK (on_x11_display_closing), manager);
- meta_xwayland_init_dnd (xdisplay);
add_local_user_to_xhost (xdisplay);
- meta_xwayland_init_xrandr (manager, xdisplay);
-
- x11_display_policy =
- meta_context_get_x11_display_policy (compositor->context);
- if (x11_display_policy == META_X11_DISPLAY_POLICY_ON_DEMAND)
- {
- meta_xwayland_stop_xserver_timeout (manager);
- g_signal_connect (meta_get_display (), "window-created",
- G_CALLBACK (window_created_cb), manager);
- }
}
static void
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index 502b1a9622..7b89cac248 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -1151,7 +1151,13 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
#ifdef HAVE_WAYLAND
if (meta_is_wayland_compositor ())
- meta_xwayland_complete_init (display, xdisplay);
+ {
+ MetaContext *context = meta_display_get_context (display);
+ MetaWaylandCompositor *compositor =
+ meta_context_get_wayland_compositor (context);
+
+ meta_xwayland_setup_xdisplay (&compositor->xwayland_manager, xdisplay);
+ }
#endif
if (meta_is_syncing ())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]