From 5bc8823701ebd2766a4bd77302aa48ff2e0d9899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 20 Apr 2021 18:41:07 +0200 Subject: [PATCH] xwayland: Don't fetch global when shutting down DND It might not be there when shutting down, so get it from a more managed place. Note that this isn't strictly needed right now, but eventually, the MetaWaylandCompositor pointer will be cleared using a g_clear*() helper, which clears the pointer before freeing the instance, which wouldn't work here. Part-of: --- src/wayland/meta-xwayland-dnd.c | 5 ++--- src/wayland/meta-xwayland-private.h | 3 ++- src/wayland/meta-xwayland.c | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/wayland/meta-xwayland-dnd.c b/src/wayland/meta-xwayland-dnd.c index de61ccf73..a3148ed95 100644 --- a/src/wayland/meta-xwayland-dnd.c +++ b/src/wayland/meta-xwayland-dnd.c @@ -976,10 +976,9 @@ meta_xwayland_init_dnd (Display *xdisplay) } void -meta_xwayland_shutdown_dnd (Display *xdisplay) +meta_xwayland_shutdown_dnd (MetaXWaylandManager *manager, + Display *xdisplay) { - MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); - MetaXWaylandManager *manager = &compositor->xwayland_manager; MetaXWaylandDnd *dnd = manager->dnd; g_assert (dnd != NULL); diff --git a/src/wayland/meta-xwayland-private.h b/src/wayland/meta-xwayland-private.h index bba0934bd..2e38f380d 100644 --- a/src/wayland/meta-xwayland-private.h +++ b/src/wayland/meta-xwayland-private.h @@ -41,7 +41,8 @@ meta_xwayland_handle_xevent (XEvent *event); /* wl_data_device/X11 selection interoperation */ void meta_xwayland_init_dnd (Display *xdisplay); -void meta_xwayland_shutdown_dnd (Display *xdisplay); +void meta_xwayland_shutdown_dnd (MetaXWaylandManager *manager, + Display *xdisplay); gboolean meta_xwayland_dnd_handle_event (XEvent *xevent); const MetaWaylandDragDestFuncs * meta_xwayland_selection_get_drag_dest_funcs (void); diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c index 325e99a92..9926f63d4 100644 --- a/src/wayland/meta-xwayland.c +++ b/src/wayland/meta-xwayland.c @@ -1208,17 +1208,18 @@ monitors_changed_cb (MetaMonitorManager *monitor_manager) } static void -on_x11_display_closing (MetaDisplay *display) +on_x11_display_closing (MetaDisplay *display, + MetaXWaylandManager *manager) { Display *xdisplay = meta_x11_display_get_xdisplay (display->x11_display); - meta_xwayland_shutdown_dnd (xdisplay); + meta_xwayland_shutdown_dnd (manager, xdisplay); g_signal_handlers_disconnect_by_func (meta_monitor_manager_get (), monitors_changed_cb, NULL); g_signal_handlers_disconnect_by_func (display, on_x11_display_closing, - NULL); + manager); } static void @@ -1262,7 +1263,7 @@ meta_xwayland_complete_init (MetaDisplay *display, #endif g_signal_connect (display, "x11-display-closing", - G_CALLBACK (on_x11_display_closing), NULL); + G_CALLBACK (on_x11_display_closing), manager); meta_xwayland_init_dnd (xdisplay); add_local_user_to_xhost (xdisplay); meta_xwayland_init_xrandr (manager, xdisplay);