seat: allow compositors to not load a keymap

The protocol allows compositors to not send any keymap to Wayland
clients. Handle a keymap-less keyboard correctly by sending
WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP instead of erroring out in the
mmap call.
This commit is contained in:
Simon Ser 2021-08-06 21:25:55 +02:00 committed by Kenny Levinsen
parent d48ffac56b
commit c27263c105
1 changed files with 7 additions and 0 deletions

View File

@ -370,6 +370,13 @@ static void seat_client_send_keymap(struct wlr_seat_client *client,
continue;
}
if (keyboard->keymap == NULL) {
wl_keyboard_send_keymap(resource,
WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP, keymap_fd, 0);
close(keymap_fd);
continue;
}
void *ptr = mmap(NULL, keyboard->keymap_size, PROT_READ | PROT_WRITE,
MAP_SHARED, keymap_fd, 0);
if (ptr == MAP_FAILED) {