summaryrefslogtreecommitdiff
path: root/1142.patch
blob: 13b24fe1a8151e89359eb65b95308b12a3d2e81a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
From 299902b008c3b453596679f249eec28bfc6c026a Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Mon, 21 Oct 2019 20:19:06 +0200
Subject: [PATCH 1/2] 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])
-- 
2.22.0


From 7a891eeb6def29f6562a3833c272b0cb2a67ae23 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Mon, 21 Oct 2019 20:27:12 +0200
Subject: [PATCH 2/2] gdk: Do not call gdk_selection_owner_set() internally to
 the backend

This should just be called by the upper layers (and result in
wl_data_device.set_selection, etc). We should not trigger this within
the backend otherwise.

Related: https://gitlab.gnome.org/GNOME/mutter/issues/878
---
 gdk/wayland/gdkselection-wayland.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c
index 9494489d69..e14f50de8d 100644
--- a/gdk/wayland/gdkselection-wayland.c
+++ b/gdk/wayland/gdkselection-wayland.c
@@ -937,7 +937,6 @@ data_source_cancelled (void                  *data,
     gdk_drag_context_cancel (context, GDK_DRAG_CANCEL_ERROR);
 
   emit_selection_clear (display, atom);
-  gdk_selection_owner_set (NULL, atom, GDK_CURRENT_TIME, TRUE);
   gdk_wayland_selection_unset_data_source (display, atom);
 }
 
@@ -1048,7 +1047,6 @@ primary_source_cancelled (void                                *data,
 
   atom = atoms[ATOM_PRIMARY];
   emit_selection_clear (display, atom);
-  gdk_selection_owner_set (NULL, atom, GDK_CURRENT_TIME, TRUE);
   gdk_wayland_selection_unset_data_source (display, atom);
 }
 
-- 
2.22.0

bgstack15