aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVäinö Mäkelä <vaino.o.makela@gmail.com>2023-06-01 14:08:28 +0300
committerSimon Ser <contact@emersion.fr>2023-06-03 10:43:12 +0000
commitbcb69b1827aa45d5163452253f474f5cf2d23791 (patch)
tree6f3aa37c6a4fc11d0e49b555345e62b27bd94baf
parent247e86dca9917b279e9b932805763a5bb1dc7bb2 (diff)
primary-selection: Handle inert seats
-rw-r--r--types/wlr_primary_selection_v1.c22
1 files 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) {