mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
input: ignore keymap if we don’t recognize its format
This commit is contained in:
parent
85220a5543
commit
3fa3c58c8b
1 changed files with 26 additions and 9 deletions
35
input.c
35
input.c
|
|
@ -446,15 +446,9 @@ keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
|
|||
struct seat *seat = data;
|
||||
struct wayland *wayl = seat->wayl;
|
||||
|
||||
char *map_str = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (map_str == MAP_FAILED) {
|
||||
LOG_ERRNO("failed to mmap keyboard keymap");
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
while (map_str[size - 1] == '\0')
|
||||
size--;
|
||||
/*
|
||||
* Free old keymap state
|
||||
*/
|
||||
|
||||
if (seat->kbd.xkb_compose_state != NULL) {
|
||||
xkb_compose_state_unref(seat->kbd.xkb_compose_state);
|
||||
|
|
@ -487,6 +481,29 @@ keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
|
|||
|
||||
tll_free(seat->mouse.bindings);
|
||||
|
||||
/* Verify keymap is in a format we understand */
|
||||
switch ((enum wl_keyboard_keymap_format)format) {
|
||||
case WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP:
|
||||
return;
|
||||
|
||||
case WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1:
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_WARN("unrecognized keymap format: %u", format);
|
||||
return;
|
||||
}
|
||||
|
||||
char *map_str = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (map_str == MAP_FAILED) {
|
||||
LOG_ERRNO("failed to mmap keyboard keymap");
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
while (map_str[size - 1] == '\0')
|
||||
size--;
|
||||
|
||||
seat->kbd.xkb = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
|
||||
if (seat->kbd.xkb != NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue