aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-12-09 17:35:11 +0100
committeremersion <contact@emersion.fr>2019-01-24 12:18:41 +0100
commita1f9d7ad9efbd248ceb85307a51e6dcf27f6bb25 (patch)
tree065b5a6aad0ad3bd4532b539d83bc8178ba2dc2b
parent909b3b16f3b7634dff02030123637ae94a012850 (diff)
data-device: keep track of wlr_data_offer in wlr_seat lists
-rw-r--r--include/wlr/types/wlr_data_device.h1
-rw-r--r--include/wlr/types/wlr_seat.h2
-rw-r--r--types/data_device/wlr_data_offer.c11
-rw-r--r--types/seat/wlr_seat.c2
4 files changed, 16 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h
index e82dfa60..59aa718f 100644
--- a/include/wlr/types/wlr_data_device.h
+++ b/include/wlr/types/wlr_data_device.h
@@ -44,6 +44,7 @@ struct wlr_data_offer {
struct wl_resource *resource;
struct wlr_data_source *source;
enum wlr_data_offer_type type;
+ struct wl_list link; // wlr_seat::{selection_offers,drag_offers}
uint32_t actions;
enum wl_data_device_manager_dnd_action preferred_action;
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index 6bc4af1a..f6df7413 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -197,6 +197,7 @@ struct wlr_seat {
struct wlr_data_source *selection_source;
uint32_t selection_serial;
+ struct wl_list selection_offers; // wlr_data_offer::link
struct wlr_primary_selection_source *primary_selection_source;
uint32_t primary_selection_serial;
@@ -205,6 +206,7 @@ struct wlr_seat {
struct wlr_drag *drag;
struct wlr_data_source *drag_source;
uint32_t drag_serial;
+ struct wl_list drag_offers; // wlr_data_offer::link
struct wlr_seat_pointer_state pointer_state;
struct wlr_seat_keyboard_state keyboard_state;
diff --git a/types/data_device/wlr_data_offer.c b/types/data_device/wlr_data_offer.c
index b610e4ac..0b0332b1 100644
--- a/types/data_device/wlr_data_offer.c
+++ b/types/data_device/wlr_data_offer.c
@@ -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);
diff --git a/types/seat/wlr_seat.c b/types/seat/wlr_seat.c
index eba204dd..3595be15 100644
--- a/types/seat/wlr_seat.c
+++ b/types/seat/wlr_seat.c
@@ -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);