data-device: keep track of wlr_data_offer in wlr_seat lists

This commit is contained in:
emersion 2018-12-09 17:35:11 +01:00
parent 909b3b16f3
commit a1f9d7ad9e
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
4 changed files with 16 additions and 0 deletions

View file

@ -181,9 +181,11 @@ void data_offer_destroy(struct wlr_data_offer *offer) {
}
wl_list_remove(&offer->source_destroy.link);
wl_list_remove(&offer->link);
// Make the resource inert
wl_resource_set_user_data(offer->resource, NULL);
free(offer);
}
@ -232,6 +234,15 @@ struct wlr_data_offer *data_offer_create(struct wl_resource *device_resource,
wl_resource_set_implementation(offer->resource, &data_offer_impl, offer,
data_offer_handle_resource_destroy);
switch (type) {
case WLR_DATA_OFFER_SELECTION:
wl_list_insert(&seat_client->seat->selection_offers, &offer->link);
break;
case WLR_DATA_OFFER_DRAG:
wl_list_insert(&seat_client->seat->drag_offers, &offer->link);
break;
}
offer->source_destroy.notify = data_offer_handle_source_destroy;
wl_signal_add(&source->events.destroy, &offer->source_destroy);

View file

@ -267,6 +267,8 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
seat->name = strdup(name);
wl_list_init(&seat->clients);
wl_list_init(&seat->drag_icons);
wl_list_init(&seat->selection_offers);
wl_list_init(&seat->drag_offers);
wl_signal_init(&seat->events.start_drag);
wl_signal_init(&seat->events.new_drag_icon);