seat/keyboard: skip wl_array allocation
We can just create a wl_array from the array passed by the user. Here, wl_array is only necessary to make libwayland happy.
This commit is contained in:
parent
90d7bce994
commit
f41dcb3a97
|
@ -254,17 +254,10 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat,
|
||||||
|
|
||||||
// enter the current surface
|
// enter the current surface
|
||||||
if (client != NULL) {
|
if (client != NULL) {
|
||||||
struct wl_array keys;
|
struct wl_array keys = {
|
||||||
wl_array_init(&keys);
|
.data = keycodes,
|
||||||
for (size_t i = 0; i < num_keycodes; ++i) {
|
.size = num_keycodes * sizeof(keycodes[0]),
|
||||||
uint32_t *p = wl_array_add(&keys, sizeof(uint32_t));
|
};
|
||||||
if (!p) {
|
|
||||||
wlr_log(WLR_ERROR, "Cannot allocate memory, skipping keycode: %" PRIu32 "\n",
|
|
||||||
keycodes[i]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
*p = keycodes[i];
|
|
||||||
}
|
|
||||||
uint32_t serial = wlr_seat_client_next_serial(client);
|
uint32_t serial = wlr_seat_client_next_serial(client);
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
wl_resource_for_each(resource, &client->keyboards) {
|
wl_resource_for_each(resource, &client->keyboards) {
|
||||||
|
@ -273,7 +266,6 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat,
|
||||||
}
|
}
|
||||||
wl_keyboard_send_enter(resource, serial, surface->resource, &keys);
|
wl_keyboard_send_enter(resource, serial, surface->resource, &keys);
|
||||||
}
|
}
|
||||||
wl_array_release(&keys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// reinitialize the focus destroy events
|
// reinitialize the focus destroy events
|
||||||
|
|
Loading…
Reference in New Issue