From 06467d2e1233d8c2830500ca399bcce8dd37a91b Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 21 Jan 2019 19:23:40 +0100 Subject: primary-selection: add a serial argument The serial needs to be bumped when X11 clients set the selection, otherwise some Wayland clients (e.g. GTK) will overwrite it when they gain focus. --- include/wlr/types/wlr_data_device.h | 6 ++++-- include/wlr/types/wlr_gtk_primary_selection.h | 1 - include/wlr/types/wlr_primary_selection.h | 8 +++++++- include/wlr/types/wlr_seat.h | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h index 9c4ce995..209d917d 100644 --- a/include/wlr/types/wlr_data_device.h +++ b/include/wlr/types/wlr_data_device.h @@ -166,8 +166,10 @@ void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager); void wlr_seat_client_send_selection(struct wlr_seat_client *seat_client); /** - * Sets the current selection for the seat. This removes the previous one if - * there was any. + * Sets the current selection for the seat. NULL can be provided to clear it. + * This removes the previous one if there was any. In case the selection doesn't + * come from a client, wl_display_next_serial() can be used to generate a + * serial. */ void wlr_seat_set_selection(struct wlr_seat *seat, struct wlr_data_source *source, uint32_t serial); diff --git a/include/wlr/types/wlr_gtk_primary_selection.h b/include/wlr/types/wlr_gtk_primary_selection.h index 436a50d2..7cf34201 100644 --- a/include/wlr/types/wlr_gtk_primary_selection.h +++ b/include/wlr/types/wlr_gtk_primary_selection.h @@ -36,7 +36,6 @@ struct wlr_gtk_primary_selection_device { struct wl_list resources; // wl_resource_get_link struct wl_list offers; // wl_resource_get_link - uint32_t selection_serial; struct wl_listener seat_destroy; struct wl_listener seat_focus_change; diff --git a/include/wlr/types/wlr_primary_selection.h b/include/wlr/types/wlr_primary_selection.h index 9be61acc..a2b23574 100644 --- a/include/wlr/types/wlr_primary_selection.h +++ b/include/wlr/types/wlr_primary_selection.h @@ -48,7 +48,13 @@ void wlr_primary_selection_source_send( struct wlr_primary_selection_source *source, const char *mime_type, int fd); +/** + * Sets the current primary selection for the seat. NULL can be provided to + * clear it. This removes the previous one if there was any. In case the + * selection doesn't come from a client, wl_display_next_serial() can be used to + * generate a serial. + */ void wlr_seat_set_primary_selection(struct wlr_seat *seat, - struct wlr_primary_selection_source *source); + struct wlr_primary_selection_source *source, uint32_t serial); #endif diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 942a3420..1ad5542e 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -200,6 +200,7 @@ struct wlr_seat { uint32_t selection_serial; struct wlr_primary_selection_source *primary_selection_source; + uint32_t primary_selection_serial; // `drag` goes away before `drag_source`, when the implicit grab ends struct wlr_drag *drag; -- cgit v1.2.3