data-device: make device inert when seat is destroyed

This commit is contained in:
emersion 2018-12-09 16:58:31 +01:00
parent 9d6cb85b2d
commit 3f82eb1853
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 16 additions and 5 deletions

View File

@ -26,6 +26,9 @@ static void data_device_set_selection(struct wl_client *client,
struct wl_resource *source_resource, uint32_t serial) { struct wl_resource *source_resource, uint32_t serial) {
struct wlr_seat_client *seat_client = struct wlr_seat_client *seat_client =
seat_client_from_data_device_resource(device_resource); seat_client_from_data_device_resource(device_resource);
if (seat_client == NULL) {
return;
}
struct wlr_client_data_source *source = NULL; struct wlr_client_data_source *source = NULL;
if (source_resource != NULL) { if (source_resource != NULL) {
@ -48,6 +51,10 @@ static void data_device_start_drag(struct wl_client *client,
uint32_t serial) { uint32_t serial) {
struct wlr_seat_client *seat_client = struct wlr_seat_client *seat_client =
seat_client_from_data_device_resource(device_resource); 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_surface *origin = wlr_surface_from_resource(origin_resource);
struct wlr_client_data_source *source = NULL; 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 = struct wlr_seat_client *seat_client =
wlr_seat_client_from_resource(seat_resource); wlr_seat_client_from_resource(seat_resource);
uint32_t version = wl_resource_get_version(manager_resource);
struct wl_resource *resource = wl_resource_create(client, struct wl_resource *resource = wl_resource_create(client,
&wl_data_device_interface, wl_resource_get_version(manager_resource), &wl_data_device_interface, version, id);
id);
if (resource == NULL) { if (resource == NULL) {
wl_resource_post_no_memory(manager_resource); wl_resource_post_no_memory(manager_resource);
return; return;
@ -244,8 +251,7 @@ static void data_device_manager_bind(struct wl_client *client,
struct wlr_data_device_manager *manager = data; struct wlr_data_device_manager *manager = data;
struct wl_resource *resource = wl_resource_create(client, struct wl_resource *resource = wl_resource_create(client,
&wl_data_device_manager_interface, &wl_data_device_manager_interface, version, id);
version, id);
if (resource == NULL) { if (resource == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;

View File

@ -86,7 +86,12 @@ static void seat_client_handle_resource_destroy(
wl_resource_destroy(resource); wl_resource_destroy(resource);
} }
wl_resource_for_each_safe(resource, tmp, &client->data_devices) { 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); wl_list_remove(&client->link);