data-device: send offer on get_data_device

This commit is contained in:
emersion 2018-12-09 13:22:09 +01:00
parent 84f278eca1
commit 1a2727cc38
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 28 additions and 13 deletions

View File

@ -93,14 +93,12 @@ static void data_device_handle_resource_destroy(struct wl_resource *resource) {
} }
void wlr_seat_client_send_selection(struct wlr_seat_client *seat_client) { static void device_resource_send_selection(struct wl_resource *device_resource) {
struct wlr_data_source *source = seat_client->seat->selection_source; struct wlr_seat_client *seat_client =
if (source != NULL) { seat_client_from_data_device_resource(device_resource);
source->accepted = false; assert(seat_client != NULL);
}
struct wl_resource *device_resource; struct wlr_data_source *source = seat_client->seat->selection_source;
wl_resource_for_each(device_resource, &seat_client->data_devices) {
if (source != NULL) { if (source != NULL) {
struct wlr_data_offer *offer = struct wlr_data_offer *offer =
data_offer_create(device_resource, source); data_offer_create(device_resource, source);
@ -114,6 +112,17 @@ void wlr_seat_client_send_selection(struct wlr_seat_client *seat_client) {
wl_data_device_send_selection(device_resource, NULL); wl_data_device_send_selection(device_resource, NULL);
} }
} }
void wlr_seat_client_send_selection(struct wlr_seat_client *seat_client) {
struct wlr_data_source *source = seat_client->seat->selection_source;
if (source != NULL) {
source->accepted = false;
}
struct wl_resource *device_resource;
wl_resource_for_each(device_resource, &seat_client->data_devices) {
device_resource_send_selection(device_resource);
}
} }
void wlr_seat_request_set_selection(struct wlr_seat *seat, void wlr_seat_request_set_selection(struct wlr_seat *seat,
@ -202,8 +211,14 @@ static void data_device_manager_get_data_device(struct wl_client *client,
return; return;
} }
wl_resource_set_implementation(resource, &data_device_impl, seat_client, wl_resource_set_implementation(resource, &data_device_impl, seat_client,
&data_device_handle_resource_destroy); data_device_handle_resource_destroy);
wl_list_insert(&seat_client->data_devices, wl_resource_get_link(resource)); wl_list_insert(&seat_client->data_devices, wl_resource_get_link(resource));
struct wlr_seat_client *focused_client =
seat_client->seat->keyboard_state.focused_client;
if (focused_client == seat_client) {
device_resource_send_selection(resource);
}
} }
static void data_device_manager_create_data_source(struct wl_client *client, static void data_device_manager_create_data_source(struct wl_client *client,