summaryrefslogtreecommitdiff
path: root/gdk/wayland/gdkselection-wayland.c
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2017-11-28 17:44:06 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2017-11-29 11:29:30 +0100
commitff3da0818c4cad3232137faf082b38519f7ef4ad (patch)
tree59f442c7898bc2d22ea31c04f6ff4462882659c6 /gdk/wayland/gdkselection-wayland.c
parent93f6f253ea123860561451c9a0edbd5e0b7504b7 (diff)
downloadgtk+-ff3da0818c4cad3232137faf082b38519f7ef4ad.tar.gz
wayland: emit GDK_SELECTION_CLEAR on owner changes
The wayland backend currently never emits GDK_SELECTION_CLEAR events. GtkClipboard uses this signal in order to clear the clipboard owner when the selection is set to something outside the application. This commit ensures the wayland backend emits GDK_SELECTION_CLEAR before setting the clipboard owner to NULL, as this means we lost the selection. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> https://bugzilla.gnome.org/show_bug.cgi?id=790031
Diffstat (limited to 'gdk/wayland/gdkselection-wayland.c')
-rw-r--r--gdk/wayland/gdkselection-wayland.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c
index e8f9453a8b..45d89f8f65 100644
--- a/gdk/wayland/gdkselection-wayland.c
+++ b/gdk/wayland/gdkselection-wayland.c
@@ -113,6 +113,7 @@ struct _GdkWaylandSelection
static void selection_buffer_read (SelectionBuffer *buffer);
static void async_write_data_write (AsyncWriteData *write_data);
+static void emit_selection_clear (GdkDisplay *display, GdkAtom selection);
static void
selection_buffer_notify (SelectionBuffer *buffer)
@@ -930,6 +931,7 @@ data_source_cancelled (void *data,
if (context)
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);
}
@@ -1040,6 +1042,7 @@ primary_source_cancelled (void *data,
display = gdk_display_get_default ();
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);
}
@@ -1281,6 +1284,27 @@ emit_empty_selection_notify (GdkWindow *requestor,
gdk_event_free (event);
}
+static void
+emit_selection_clear (GdkDisplay *display,
+ GdkAtom selection)
+{
+ GdkEvent *event;
+ GdkWindow *window;
+
+ event = gdk_event_new (GDK_SELECTION_CLEAR);
+ event->selection.selection = selection;
+ event->selection.time = GDK_CURRENT_TIME;
+
+ window = _gdk_wayland_display_get_selection_owner (display, selection);
+ if (window != NULL) {
+ event->selection.window = g_object_ref (window);
+ event->selection.requestor = g_object_ref (window);
+ }
+
+ gdk_event_put (event);
+ gdk_event_free (event);
+}
+
void
_gdk_wayland_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,