Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

data-control: Don't send offers to the clients that sent them #2408

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion protocol/wlr-data-control-unstable-v1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@
the primary clipboard selections). Immediately following the
wlr_data_control_device.data_offer event, the new data_offer object
will send out wlr_data_control_offer.offer events to describe the MIME
types it offers.
types it offers. Offers will be propagated to other listening clients
except for the client that made the offer.
</description>
<arg name="id" type="new_id" interface="zwlr_data_control_offer_v1"/>
</event>
Expand Down
22 changes: 22 additions & 0 deletions types/wlr_data_control_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,17 @@ static void control_send_selection(struct wlr_data_control_device_v1 *device) {
}

device->selection_offer_resource = NULL;

struct client_data_source *client_source =
wl_container_of(source, client_source, source);
if (client_source && device->resource) {
struct wl_resource *source_resource = client_source->resource;
// Don't send the offer back to the client that sent it
if (source_resource && wl_resource_get_client(source_resource) ==
wl_resource_get_client(device->resource))
return;
}

if (source != NULL) {
device->selection_offer_resource =
create_offer(device, &source->mime_types, false);
Expand Down Expand Up @@ -488,6 +499,17 @@ static void control_send_primary_selection(
}

device->primary_selection_offer_resource = NULL;

struct client_primary_selection_source *client_source =
wl_container_of(source, client_source, source);
if (client_source && device->resource) {
struct wl_resource *source_resource = client_source->resource;
// Don't send the offer back to the client that sent it
if (source_resource && wl_resource_get_client(source_resource) ==
wl_resource_get_client(device->resource))
return;
}

if (source != NULL) {
device->primary_selection_offer_resource =
create_offer(device, &source->mime_types, true);
Expand Down