mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 04:45:58 +01:00
data-device: keep track of wlr_data_offer in wlr_seat lists
This commit is contained in:
parent
909b3b16f3
commit
a1f9d7ad9e
4 changed files with 16 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue