[mutter] x11/selection: Unset selection ownership on shutdown



commit 9930b5d7ca1181f36c2229b2c70ff8c4a249a15c
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Apr 5 22:11:20 2022 +0200

    x11/selection: Unset selection ownership on shutdown
    
    This makes sure we don't accidentally try to paste from past Xwayland
    connection instances.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>

 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 e389f22c7c..cf50e635d7 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]);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]