[gtk/wip/carlosg/avoid-selection-clear: 1/2] gdk: Shuffle the situations where a selection is unset



commit 299902b008c3b453596679f249eec28bfc6c026a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Oct 21 20:19:06 2019 +0200

    gdk: Shuffle the situations where a selection is unset
    
    This should only be explicitly unset (face to the windowing) on
    gdk_selection_owner_set() with a NULL window. Other circumstances
    (eg. selection being taken over by another client) should just
    trigger the SelectionClear event in GDK internally.
    
    Related: https://gitlab.gnome.org/GNOME/mutter/issues/878

 gdk/wayland/gdkselection-wayland.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c
index cb799e53e0..9494489d69 100644
--- a/gdk/wayland/gdkselection-wayland.c
+++ b/gdk/wayland/gdkselection-wayland.c
@@ -1140,10 +1140,6 @@ gdk_wayland_selection_unset_data_source (GdkDisplay *display,
 
   if (selection == atoms[ATOM_CLIPBOARD])
     {
-      GdkSeat *seat = gdk_display_get_default_seat (display);
-
-      gdk_wayland_seat_set_selection (seat, NULL);
-
       if (wayland_selection->clipboard_source)
         {
           wl_data_source_destroy (wayland_selection->clipboard_source);
@@ -1152,10 +1148,6 @@ gdk_wayland_selection_unset_data_source (GdkDisplay *display,
     }
   else if (selection == atoms[ATOM_PRIMARY])
     {
-      GdkSeat *seat = gdk_display_get_default_seat (display);
-
-      gdk_wayland_seat_set_primary (seat, NULL);
-
       if (wayland_selection->primary_source)
         {
           gtk_primary_selection_source_destroy (wayland_selection->primary_source);
@@ -1192,19 +1184,26 @@ _gdk_wayland_display_set_selection_owner (GdkDisplay *display,
                                           gboolean    send_event)
 {
   GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display);
+  GdkSeat *seat = gdk_display_get_default_seat (display);
 
   if (selection == atoms[ATOM_CLIPBOARD])
     {
       wayland_selection->clipboard_owner = owner;
       if (send_event && !owner)
-        gdk_wayland_selection_unset_data_source (display, selection);
+        {
+          gdk_wayland_seat_set_selection (seat, NULL);
+          gdk_wayland_selection_unset_data_source (display, selection);
+        }
       return TRUE;
     }
   else if (selection == atoms[ATOM_PRIMARY])
     {
       wayland_selection->primary_owner = owner;
       if (send_event && !owner)
-        gdk_wayland_selection_unset_data_source (display, selection);
+        {
+          gdk_wayland_seat_set_primary (seat, NULL);
+          gdk_wayland_selection_unset_data_source (display, selection);
+        }
       return TRUE;
     }
   else if (selection == atoms[ATOM_DND])


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