From bcb69b1827aa45d5163452253f474f5cf2d23791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A4in=C3=B6=20M=C3=A4kel=C3=A4?= Date: Thu, 1 Jun 2023 14:08:28 +0300 Subject: [PATCH] primary-selection: Handle inert seats --- types/wlr_primary_selection_v1.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/types/wlr_primary_selection_v1.c b/types/wlr_primary_selection_v1.c index 511d5ddb..218595b2 100644 --- a/types/wlr_primary_selection_v1.c +++ b/types/wlr_primary_selection_v1.c @@ -397,13 +397,6 @@ static void device_manager_handle_get_device(struct wl_client *client, struct wlr_primary_selection_v1_device_manager *manager = manager_from_resource(manager_resource); - struct wlr_primary_selection_v1_device *device = - get_or_create_device(manager, seat_client->seat); - if (device == NULL) { - wl_resource_post_no_memory(manager_resource); - return; - } - uint32_t version = wl_resource_get_version(manager_resource); struct wl_resource *resource = wl_resource_create(client, &zwp_primary_selection_device_v1_interface, version, id); @@ -411,8 +404,21 @@ static void device_manager_handle_get_device(struct wl_client *client, wl_resource_post_no_memory(manager_resource); return; } - wl_resource_set_implementation(resource, &device_impl, device, + wl_resource_set_implementation(resource, &device_impl, NULL, device_handle_resource_destroy); + wl_list_init(wl_resource_get_link(resource)); + if (seat_client == NULL) { + return; + } + + struct wlr_primary_selection_v1_device *device = + get_or_create_device(manager, seat_client->seat); + if (device == NULL) { + wl_resource_destroy(resource); + wl_resource_post_no_memory(manager_resource); + return; + } + wl_resource_set_user_data(resource, device); wl_list_insert(&device->resources, wl_resource_get_link(resource)); if (device->seat->keyboard_state.focused_client == seat_client) {