wayland: Add a prepare-shutdown signal
This allows moving the xwayland shutdown logic to the xwayland implementation Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2399>
This commit is contained in:
parent
f7c55d478a
commit
36f30341ac
@ -62,6 +62,8 @@ struct _MetaXWaylandManager
|
|||||||
guint abstract_fd_watch_id;
|
guint abstract_fd_watch_id;
|
||||||
guint unix_fd_watch_id;
|
guint unix_fd_watch_id;
|
||||||
|
|
||||||
|
gulong prepare_shutdown_id;
|
||||||
|
|
||||||
struct wl_display *wayland_display;
|
struct wl_display *wayland_display;
|
||||||
struct wl_client *client;
|
struct wl_client *client;
|
||||||
struct wl_resource *xserver_resource;
|
struct wl_resource *xserver_resource;
|
||||||
|
@ -61,6 +61,15 @@
|
|||||||
#include "backends/native/meta-renderer-native.h"
|
#include "backends/native/meta-renderer-native.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PREPARE_SHUTDOWN,
|
||||||
|
|
||||||
|
N_SIGNALS
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint signals[N_SIGNALS];
|
||||||
|
|
||||||
static char *_display_name_override;
|
static char *_display_name_override;
|
||||||
|
|
||||||
typedef struct _MetaWaylandCompositorPrivate
|
typedef struct _MetaWaylandCompositorPrivate
|
||||||
@ -431,14 +440,7 @@ meta_wayland_log_func (const char *fmt,
|
|||||||
void
|
void
|
||||||
meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor)
|
meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_XWAYLAND
|
g_signal_emit (compositor, signals[PREPARE_SHUTDOWN], 0, NULL);
|
||||||
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
|
|
||||||
|
|
||||||
if (compositor->wayland_display)
|
if (compositor->wayland_display)
|
||||||
wl_display_destroy_clients (compositor->wayland_display);
|
wl_display_destroy_clients (compositor->wayland_display);
|
||||||
@ -492,6 +494,14 @@ meta_wayland_compositor_class_init (MetaWaylandCompositorClass *klass)
|
|||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->finalize = meta_wayland_compositor_finalize;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XWAYLAND
|
#ifdef HAVE_XWAYLAND
|
||||||
|
@ -38,9 +38,6 @@ void
|
|||||||
meta_xwayland_setup_xdisplay (MetaXWaylandManager *manager,
|
meta_xwayland_setup_xdisplay (MetaXWaylandManager *manager,
|
||||||
Display *xdisplay);
|
Display *xdisplay);
|
||||||
|
|
||||||
void
|
|
||||||
meta_xwayland_shutdown (MetaXWaylandManager *manager);
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_xwayland_handle_xevent (XEvent *event);
|
meta_xwayland_handle_xevent (XEvent *event);
|
||||||
|
|
||||||
|
@ -468,6 +468,7 @@ meta_xwayland_terminate (MetaXWaylandManager *manager)
|
|||||||
|
|
||||||
meta_display_shutdown_x11 (display);
|
meta_display_shutdown_x11 (display);
|
||||||
meta_xwayland_stop_xserver (manager);
|
meta_xwayland_stop_xserver (manager);
|
||||||
|
g_clear_signal_handler (&manager->prepare_shutdown_id, manager->compositor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -510,11 +511,13 @@ x_io_error_exit (Display *display,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_XSETIOERROREXITHANDLER
|
||||||
static void
|
static void
|
||||||
x_io_error_exit_noop (Display *display,
|
x_io_error_exit_noop (Display *display,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_xwayland_override_display_number (int number)
|
meta_xwayland_override_display_number (int number)
|
||||||
@ -995,6 +998,63 @@ meta_xwayland_stop_xserver (MetaXWaylandManager *manager)
|
|||||||
g_clear_object (&manager->proc);
|
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
|
gboolean
|
||||||
meta_xwayland_init (MetaXWaylandManager *manager,
|
meta_xwayland_init (MetaXWaylandManager *manager,
|
||||||
MetaWaylandCompositor *compositor,
|
MetaWaylandCompositor *compositor,
|
||||||
@ -1057,6 +1117,11 @@ meta_xwayland_init (MetaXWaylandManager *manager,
|
|||||||
xdisplay_connection_activity_cb, manager);
|
xdisplay_connection_activity_cb, manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (policy != META_X11_DISPLAY_POLICY_DISABLED)
|
||||||
|
manager->prepare_shutdown_id = g_signal_connect (compositor, "prepare-shutdown",
|
||||||
|
G_CALLBACK (meta_xwayland_shutdown),
|
||||||
|
NULL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1145,60 +1210,6 @@ meta_xwayland_setup_xdisplay (MetaXWaylandManager *manager,
|
|||||||
XFixesSetClientDisconnectMode (xdisplay, XFixesClientDisconnectFlagTerminate);
|
XFixesSetClientDisconnectMode (xdisplay, XFixesClientDisconnectFlagTerminate);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
MetaContext *context =
|
|
||||||
meta_wayland_compositor_get_context (manager->compositor);
|
|
||||||
MetaDisplay *display = meta_context_get_display (context);
|
|
||||||
MetaX11Display *x11_display;
|
|
||||||
char path[256];
|
|
||||||
|
|
||||||
g_cancellable_cancel (manager->xserver_died_cancellable);
|
|
||||||
|
|
||||||
XSetIOErrorHandler (x_io_error_noop);
|
|
||||||
x11_display = display->x11_display;
|
|
||||||
if (x11_display)
|
|
||||||
{
|
|
||||||
XSetIOErrorExitHandler (meta_x11_display_get_xdisplay (x11_display),
|
|
||||||
x_io_error_exit_noop, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
static void
|
||||||
meta_xwayland_set_primary_output (MetaX11Display *x11_display)
|
meta_xwayland_set_primary_output (MetaX11Display *x11_display)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user