[mutter/bilelmoussaoui/without-xwayland: 32/34] wayland: Add a prepare-shutdown signal
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/bilelmoussaoui/without-xwayland: 32/34] wayland: Add a prepare-shutdown signal
- Date: Tue, 2 Aug 2022 07:49:00 +0000 (UTC)
commit 6b7a4b256d8c79ba16dd758272a886fd06a0ac85
Author: Bilal Elmoussaoui <belmouss redhat com>
Date: Wed Jun 15 13:12:35 2022 +0200
wayland: Add a prepare-shutdown signal
This allows moving the xwayland shutdown logic to the xwayland
implementation
src/wayland/meta-wayland.c | 26 +++++---
src/wayland/meta-xwayland-private.h | 3 -
src/wayland/meta-xwayland.c | 117 +++++++++++++++++++-----------------
3 files changed, 79 insertions(+), 67 deletions(-)
---
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 8202933120..e8fcd9b555 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -58,6 +58,15 @@
#include "backends/native/meta-renderer-native.h"
#endif
+enum
+{
+ PREPARE_SHUTDOWN,
+
+ N_SIGNALS
+};
+
+static guint signals[N_SIGNALS];
+
static char *_display_name_override;
typedef struct _MetaWaylandCompositorPrivate
@@ -435,14 +444,7 @@ meta_wayland_log_func (const char *fmt,
void
meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor)
{
-#ifdef HAVE_XWAYLAND
- MetaX11DisplayPolicy x11_display_policy;
-
- x11_display_policy =
- meta_context_get_x11_display_policy (compositor->context);
- if (x11_display_policy != META_X11_DISPLAY_POLICY_DISABLED)
- meta_xwayland_shutdown (&compositor->xwayland_manager);
-#endif
+ g_signal_emit (compositor, signals[PREPARE_SHUTDOWN], 0, NULL);
if (compositor->wayland_display)
wl_display_destroy_clients (compositor->wayland_display);
@@ -494,6 +496,14 @@ meta_wayland_compositor_class_init (MetaWaylandCompositorClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = meta_wayland_compositor_finalize;
+
+ signals[PREPARE_SHUTDOWN] =
+ g_signal_new ("prepare-shutdown",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
}
void
diff --git a/src/wayland/meta-xwayland-private.h b/src/wayland/meta-xwayland-private.h
index b8bafc783f..53c3082d88 100644
--- a/src/wayland/meta-xwayland-private.h
+++ b/src/wayland/meta-xwayland-private.h
@@ -38,9 +38,6 @@ void
meta_xwayland_setup_xdisplay (MetaXWaylandManager *manager,
Display *xdisplay);
-void
-meta_xwayland_shutdown (MetaXWaylandManager *manager);
-
gboolean
meta_xwayland_handle_xevent (XEvent *event);
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 70f4b42793..5a1d085739 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -994,6 +994,63 @@ meta_xwayland_stop_xserver (MetaXWaylandManager *manager)
g_clear_object (&manager->proc);
}
+static void
+meta_xwayland_connection_release (MetaXWaylandConnection *connection)
+{
+ unlink (connection->lock_file);
+ g_clear_pointer (&connection->lock_file, g_free);
+}
+
+static void
+meta_xwayland_shutdown (MetaWaylandCompositor *compositor)
+{
+ MetaXWaylandManager *manager = &compositor->xwayland_manager;
+#ifdef HAVE_XSETIOERROREXITHANDLER
+ MetaDisplay *display = meta_get_display ();
+ MetaX11Display *x11_display;
+#endif
+ char path[256];
+
+ g_cancellable_cancel (manager->xserver_died_cancellable);
+
+ XSetIOErrorHandler (x_io_error_noop);
+#ifdef HAVE_XSETIOERROREXITHANDLER
+ x11_display = display->x11_display;
+ if (x11_display)
+ {
+ XSetIOErrorExitHandler (meta_x11_display_get_xdisplay (x11_display),
+ x_io_error_exit_noop, NULL);
+ }
+#endif
+
+ meta_xwayland_terminate (manager);
+
+ if (manager->public_connection.name)
+ {
+ snprintf (path, sizeof path, "%s%d", X11_TMP_UNIX_PATH,
+ manager->public_connection.display_index);
+ unlink (path);
+ g_clear_pointer (&manager->public_connection.name, g_free);
+ }
+
+ if (manager->private_connection.name)
+ {
+ snprintf (path, sizeof path, "%s%d", X11_TMP_UNIX_PATH,
+ manager->private_connection.display_index);
+ unlink (path);
+ g_clear_pointer (&manager->private_connection.name, g_free);
+ }
+
+ meta_xwayland_connection_release (&manager->public_connection);
+ meta_xwayland_connection_release (&manager->private_connection);
+
+ if (manager->auth_file)
+ {
+ unlink (manager->auth_file);
+ g_clear_pointer (&manager->auth_file, g_free);
+ }
+}
+
gboolean
meta_xwayland_init (MetaXWaylandManager *manager,
MetaWaylandCompositor *compositor,
@@ -1056,6 +1113,10 @@ meta_xwayland_init (MetaXWaylandManager *manager,
xdisplay_connection_activity_cb, manager);
}
+ if (policy != META_X11_DISPLAY_POLICY_DISABLED)
+ g_signal_connect (compositor, "prepare-shutdown",
+ G_CALLBACK (meta_xwayland_shutdown), NULL);
+
return TRUE;
}
@@ -1141,62 +1202,6 @@ meta_xwayland_setup_xdisplay (MetaXWaylandManager *manager,
add_local_user_to_xhost (xdisplay);
}
-static void
-meta_xwayland_connection_release (MetaXWaylandConnection *connection)
-{
- unlink (connection->lock_file);
- g_clear_pointer (&connection->lock_file, g_free);
-}
-
-void
-meta_xwayland_shutdown (MetaXWaylandManager *manager)
-{
-#ifdef HAVE_XSETIOERROREXITHANDLER
- MetaDisplay *display = meta_get_display ();
- MetaX11Display *x11_display;
-#endif
- char path[256];
-
- g_cancellable_cancel (manager->xserver_died_cancellable);
-
- XSetIOErrorHandler (x_io_error_noop);
-#ifdef HAVE_XSETIOERROREXITHANDLER
- x11_display = display->x11_display;
- if (x11_display)
- {
- XSetIOErrorExitHandler (meta_x11_display_get_xdisplay (x11_display),
- x_io_error_exit_noop, NULL);
- }
-#endif
-
- meta_xwayland_terminate (manager);
-
- if (manager->public_connection.name)
- {
- snprintf (path, sizeof path, "%s%d", X11_TMP_UNIX_PATH,
- manager->public_connection.display_index);
- unlink (path);
- g_clear_pointer (&manager->public_connection.name, g_free);
- }
-
- if (manager->private_connection.name)
- {
- snprintf (path, sizeof path, "%s%d", X11_TMP_UNIX_PATH,
- manager->private_connection.display_index);
- unlink (path);
- g_clear_pointer (&manager->private_connection.name, g_free);
- }
-
- meta_xwayland_connection_release (&manager->public_connection);
- meta_xwayland_connection_release (&manager->private_connection);
-
- if (manager->auth_file)
- {
- unlink (manager->auth_file);
- g_clear_pointer (&manager->auth_file, g_free);
- }
-}
-
static void
meta_xwayland_set_primary_output (MetaX11Display *x11_display)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]