aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVäinö Mäkelä <vaino.o.makela@gmail.com>2023-06-01 10:11:51 +0300
committerSimon Ser <contact@emersion.fr>2023-06-03 10:43:12 +0000
commit5120addfbb12001d543acaf0582109e01950aa59 (patch)
tree9472a564d907b5a6d5de2c6736b3a28ab6b53375
parentf97f4496de017694cd700385b9536ddd4c645ef5 (diff)
data-control: Handle inert seats
-rw-r--r--types/wlr_data_control_v1.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/types/wlr_data_control_v1.c b/types/wlr_data_control_v1.c
index 55789d4d..f148fa87 100644
--- a/types/wlr_data_control_v1.c
+++ b/types/wlr_data_control_v1.c
@@ -593,6 +593,19 @@ static void manager_handle_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,
+ &zwlr_data_control_device_v1_interface, version, id);
+ if (resource == NULL) {
+ wl_resource_post_no_memory(manager_resource);
+ return;
+ }
+ wl_resource_set_implementation(resource, &control_impl, NULL,
+ control_handle_resource_destroy);
+ if (seat_client == NULL) {
+ return;
+ }
+
struct wlr_data_control_device_v1 *device =
calloc(1, sizeof(struct wlr_data_control_device_v1));
if (device == NULL) {
@@ -601,18 +614,8 @@ static void manager_handle_get_data_device(struct wl_client *client,
}
device->manager = manager;
device->seat = seat_client->seat;
-
- uint32_t version = wl_resource_get_version(manager_resource);
- device->resource = wl_resource_create(client,
- &zwlr_data_control_device_v1_interface, version, id);
- if (device->resource == NULL) {
- wl_resource_post_no_memory(manager_resource);
- free(device);
- return;
- }
- wl_resource_set_implementation(device->resource, &control_impl, device,
- control_handle_resource_destroy);
- struct wl_resource *resource = device->resource;
+ device->resource = resource;
+ wl_resource_set_user_data(resource, device);
device->seat_destroy.notify = control_handle_seat_destroy;
wl_signal_add(&device->seat->events.destroy, &device->seat_destroy);