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.
This commit is contained in:
emersion 2019-01-21 19:23:40 +01:00
parent b619ab4d34
commit 06467d2e12
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
9 changed files with 32 additions and 19 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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

View file

@ -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;