From 7c309ba4d30d5ff99fd52a1124e251203ac80883 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 13 Mar 2020 23:06:21 +0100 Subject: [PATCH] Properly popluate keys array for enter on creation This corrects an oversight made in 3f617631cb68c0e90a755b86f9c241caf0080f9a --- types/seat/wlr_seat_keyboard.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/types/seat/wlr_seat_keyboard.c b/types/seat/wlr_seat_keyboard.c index 93e259c9..1e567ba1 100644 --- a/types/seat/wlr_seat_keyboard.c +++ b/types/seat/wlr_seat_keyboard.c @@ -421,8 +421,21 @@ void seat_client_create_keyboard(struct wlr_seat_client *seat_client, // Send an enter event if there is a focused client/surface stored if (focused_client != NULL && focused_surface != NULL) { + uint32_t *keycodes = keyboard->keycodes; + size_t num_keycodes = keyboard->num_keycodes; + struct wl_array keys; wl_array_init(&keys); + for (size_t i = 0; i < num_keycodes; ++i) { + uint32_t *p = wl_array_add(&keys, sizeof(uint32_t)); + if (!p) { + wlr_log(WLR_ERROR, "Cannot allocate memory, skipping keycode: %d\n", + keycodes[i]); + continue; + } + *p = keycodes[i]; + } + uint32_t serial = wlr_seat_client_next_serial(focused_client); struct wl_resource *resource; wl_resource_for_each(resource, &focused_client->keyboards) { @@ -434,6 +447,7 @@ void seat_client_create_keyboard(struct wlr_seat_client *seat_client, focused_surface->resource, &keys); } } + wl_array_release(&keys); } }