diff options
author | emersion <contact@emersion.fr> | 2018-12-09 16:58:31 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-01-24 12:18:39 +0100 |
commit | 3f82eb185353d64277c77f82ca727948e87c4024 (patch) | |
tree | 1e039e69df8ef98ea975510c7ac44831418e456d | |
parent | 9d6cb85b2d7d2627581b957d51944b62705562c0 (diff) |
data-device: make device inert when seat is destroyed
-rw-r--r-- | types/data_device/wlr_data_device.c | 14 | ||||
-rw-r--r-- | types/seat/wlr_seat.c | 7 |
2 files changed, 16 insertions, 5 deletions
diff --git a/types/data_device/wlr_data_device.c b/types/data_device/wlr_data_device.c index 385ad9a6..e4e56d4a 100644 --- a/types/data_device/wlr_data_device.c +++ b/types/data_device/wlr_data_device.c @@ -26,6 +26,9 @@ static void data_device_set_selection(struct wl_client *client, struct wl_resource *source_resource, uint32_t serial) { struct wlr_seat_client *seat_client = seat_client_from_data_device_resource(device_resource); + if (seat_client == NULL) { + return; + } struct wlr_client_data_source *source = NULL; if (source_resource != NULL) { @@ -48,6 +51,10 @@ static void data_device_start_drag(struct wl_client *client, uint32_t serial) { struct wlr_seat_client *seat_client = seat_client_from_data_device_resource(device_resource); + if (seat_client == NULL) { + return; + } + struct wlr_surface *origin = wlr_surface_from_resource(origin_resource); struct wlr_client_data_source *source = NULL; @@ -201,9 +208,9 @@ static void data_device_manager_get_data_device(struct wl_client *client, struct wlr_seat_client *seat_client = wlr_seat_client_from_resource(seat_resource); + uint32_t version = wl_resource_get_version(manager_resource); struct wl_resource *resource = wl_resource_create(client, - &wl_data_device_interface, wl_resource_get_version(manager_resource), - id); + &wl_data_device_interface, version, id); if (resource == NULL) { wl_resource_post_no_memory(manager_resource); return; @@ -244,8 +251,7 @@ static void data_device_manager_bind(struct wl_client *client, struct wlr_data_device_manager *manager = data; struct wl_resource *resource = wl_resource_create(client, - &wl_data_device_manager_interface, - version, id); + &wl_data_device_manager_interface, version, id); if (resource == NULL) { wl_client_post_no_memory(client); return; diff --git a/types/seat/wlr_seat.c b/types/seat/wlr_seat.c index 41dcaae6..eba204dd 100644 --- a/types/seat/wlr_seat.c +++ b/types/seat/wlr_seat.c @@ -86,7 +86,12 @@ static void seat_client_handle_resource_destroy( wl_resource_destroy(resource); } wl_resource_for_each_safe(resource, tmp, &client->data_devices) { - wl_resource_destroy(resource); + // Make the data device inert + wl_resource_set_user_data(resource, NULL); + + struct wl_list *link = wl_resource_get_link(resource); + wl_list_remove(link); + wl_list_init(link); } wl_list_remove(&client->link); |