diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c index 12737d672e..973f90cff3 100644 --- a/gdk/wayland/gdkselection-wayland.c +++ b/gdk/wayland/gdkselection-wayland.c @@ -114,6 +114,9 @@ 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 emit_empty_selection_notify (GdkWindow *requestor, + GdkAtom selection, + GdkAtom target); static void selection_buffer_notify (SelectionBuffer *buffer) @@ -168,11 +171,22 @@ selection_buffer_ref (SelectionBuffer *buffer) static void selection_buffer_unref (SelectionBuffer *buffer_data) { + GList *l; + buffer_data->ref_count--; if (buffer_data->ref_count != 0) return; + for (l = buffer_data->requestors; l; l = l->next) + { + emit_empty_selection_notify (l->data, buffer_data->selection, + buffer_data->target); + } + + g_list_free (buffer_data->requestors); + buffer_data->requestors = NULL; + if (buffer_data->cancellable) g_object_unref (buffer_data->cancellable); @@ -1313,7 +1327,10 @@ _gdk_wayland_display_convert_selection (GdkDisplay *display, selection_data = selection_lookup_offer_by_atom (wayland_selection, selection); if (!selection_data) - return; + { + emit_empty_selection_notify (requestor, selection, target); + return; + } offer = gdk_wayland_selection_get_offer (display, selection); target_list = gdk_wayland_selection_get_targets (display, selection);