diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-08-25 11:54:46 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-08-25 11:54:46 +0000 |
commit | 64fe1196437a5ba170c66962293ef9c7fa313b15 (patch) | |
tree | ef9b18d78017a9165d401a6c51ffdf8efd3f5472 | |
parent | 3857077701628ee577ed1e2fbe8a79d13bf28973 (diff) | |
parent | 6841c73808f4a72ef27ef803059c93ecc1dfc4b8 (diff) | |
download | gtk+-64fe1196437a5ba170c66962293ef9c7fa313b15.tar.gz |
Merge branch 'wip/carlosg/ensure-selection-notify' into 'gtk-3-24'
Ensure to emit GDK_SELECTION_NOTIFY on all circumstances
See merge request GNOME/gtk!1057
-rw-r--r-- | gdk/wayland/gdkdevice-wayland.c | 13 | ||||
-rw-r--r-- | gdk/wayland/gdkprivate-wayland.h | 4 | ||||
-rw-r--r-- | gdk/wayland/gdkselection-wayland.c | 37 |
3 files changed, 34 insertions, 20 deletions
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 79b08b53b2..a64f33c871 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -5324,18 +5324,15 @@ gdk_wayland_device_get_data_device (GdkDevice *gdk_device) } void -gdk_wayland_device_set_selection (GdkDevice *gdk_device, - struct wl_data_source *source) +gdk_wayland_seat_set_selection (GdkSeat *seat, + struct wl_data_source *source) { - GdkWaylandSeat *seat; + GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat); GdkWaylandDisplay *display_wayland; - g_return_if_fail (GDK_IS_WAYLAND_DEVICE (gdk_device)); - - seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (gdk_device)); - display_wayland = GDK_WAYLAND_DISPLAY (seat->display); + display_wayland = GDK_WAYLAND_DISPLAY (wayland_seat->display); - wl_data_device_set_selection (seat->data_device, source, + wl_data_device_set_selection (wayland_seat->data_device, source, _gdk_wayland_display_get_serial (display_wayland)); } diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h index 49db8d5f19..fc8e9fe280 100644 --- a/gdk/wayland/gdkprivate-wayland.h +++ b/gdk/wayland/gdkprivate-wayland.h @@ -188,8 +188,8 @@ uint32_t _gdk_wayland_device_get_implicit_grab_serial(GdkWaylandDevice *device, uint32_t _gdk_wayland_seat_get_last_implicit_grab_serial (GdkSeat *seat, GdkEventSequence **seqence); struct wl_data_device * gdk_wayland_device_get_data_device (GdkDevice *gdk_device); -void gdk_wayland_device_set_selection (GdkDevice *gdk_device, - struct wl_data_source *source); +void gdk_wayland_seat_set_selection (GdkSeat *seat, + struct wl_data_source *source); void gdk_wayland_seat_set_primary (GdkSeat *seat, struct gtk_primary_selection_source *source); diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c index 12737d672e..cb799e53e0 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); @@ -1126,11 +1140,9 @@ gdk_wayland_selection_unset_data_source (GdkDisplay *display, if (selection == atoms[ATOM_CLIPBOARD]) { - GdkDevice *device; - - device = gdk_seat_get_pointer (gdk_display_get_default_seat (display)); + GdkSeat *seat = gdk_display_get_default_seat (display); - gdk_wayland_device_set_selection (device, NULL); + gdk_wayland_seat_set_selection (seat, NULL); if (wayland_selection->clipboard_source) { @@ -1184,11 +1196,15 @@ _gdk_wayland_display_set_selection_owner (GdkDisplay *display, if (selection == atoms[ATOM_CLIPBOARD]) { wayland_selection->clipboard_owner = owner; + if (send_event && !owner) + 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); return TRUE; } else if (selection == atoms[ATOM_DND]) @@ -1313,7 +1329,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); @@ -1534,12 +1553,10 @@ gdk_wayland_selection_add_targets (GdkWindow *window, if (selection == atoms[ATOM_CLIPBOARD]) { - GdkDisplay *display; - GdkDevice *device; + GdkSeat *seat; - display = gdk_window_get_display (window); - device = gdk_seat_get_pointer (gdk_display_get_default_seat (display)); - gdk_wayland_device_set_selection (device, data_source); + seat = gdk_display_get_default_seat (display); + gdk_wayland_seat_set_selection (seat, data_source); } else if (selection == atoms[ATOM_PRIMARY]) { |