From 9930b5d7ca1181f36c2229b2c70ff8c4a249a15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 5 Apr 2022 22:11:20 +0200 Subject: [PATCH] x11/selection: Unset selection ownership on shutdown This makes sure we don't accidentally try to paste from past Xwayland connection instances. Part-of: --- src/x11/meta-x11-selection.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/x11/meta-x11-selection.c b/src/x11/meta-x11-selection.c index e389f22c7..cf50e635d 100644 --- a/src/x11/meta-x11-selection.c +++ b/src/x11/meta-x11-selection.c @@ -524,16 +524,24 @@ meta_x11_selection_init (MetaX11Display *x11_display) void meta_x11_selection_shutdown (MetaX11Display *x11_display) { - MetaDisplay *display = meta_get_display (); + MetaDisplay *display = meta_x11_display_get_display (x11_display); + MetaSelection *selection = meta_display_get_selection (display); guint i; - g_signal_handlers_disconnect_by_func (meta_display_get_selection (display), + g_signal_handlers_disconnect_by_func (selection, notify_selection_owner, x11_display); for (i = 0; i < META_N_SELECTION_TYPES; i++) { - g_clear_object (&x11_display->selection.owners[i]); + MetaSelectionSource *owner; + + owner = x11_display->selection.owners[i]; + if (owner) + { + meta_selection_unset_owner (selection, i, owner); + g_clear_object (&x11_display->selection.owners[i]); + } if (x11_display->selection.cancellables[i]) { g_cancellable_cancel (x11_display->selection.cancellables[i]);