aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--types/seat/wlr_seat.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/types/seat/wlr_seat.c b/types/seat/wlr_seat.c
index 73758569..07b75af3 100644
--- a/types/seat/wlr_seat.c
+++ b/types/seat/wlr_seat.c
@@ -176,8 +176,9 @@ static struct wlr_seat_client *seat_client_create(struct wlr_seat *wlr_seat,
static void seat_handle_bind(struct wl_client *client, void *_wlr_seat,
uint32_t version, uint32_t id) {
+ // `wlr_seat` can be NULL if the seat global is being destroyed
struct wlr_seat *wlr_seat = _wlr_seat;
- assert(client && wlr_seat);
+ assert(client);
struct wl_resource *wl_resource =
wl_resource_create(client, &wl_seat_interface, version, id);
@@ -185,6 +186,12 @@ static void seat_handle_bind(struct wl_client *client, void *_wlr_seat,
wl_client_post_no_memory(client);
return;
}
+ wl_resource_set_implementation(wl_resource, &seat_impl, NULL,
+ seat_client_handle_resource_destroy);
+ wl_list_init(wl_resource_get_link(wl_resource));
+ if (wlr_seat == NULL) {
+ return;
+ }
struct wlr_seat_client *seat_client =
wlr_seat_client_for_wl_client(wlr_seat, client);
@@ -198,8 +205,7 @@ static void seat_handle_bind(struct wl_client *client, void *_wlr_seat,
return;
}
- wl_resource_set_implementation(wl_resource, &seat_impl,
- seat_client, seat_client_handle_resource_destroy);
+ wl_resource_set_user_data(wl_resource, seat_client);
wl_list_insert(&seat_client->resources, wl_resource_get_link(wl_resource));
if (version >= WL_SEAT_NAME_SINCE_VERSION) {
wl_seat_send_name(wl_resource, wlr_seat->name);