mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-17 05:33:52 -04:00
input: keyboard: detect failure to mmap keymap
This commit is contained in:
parent
fa75e1646a
commit
307eead987
1 changed files with 17 additions and 0 deletions
17
input.c
17
input.c
|
|
@ -210,6 +210,11 @@ keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
|
||||||
struct wayland *wayl = seat->wayl;
|
struct wayland *wayl = seat->wayl;
|
||||||
|
|
||||||
char *map_str = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
char *map_str = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||||
|
if (map_str == MAP_FAILED) {
|
||||||
|
LOG_ERRNO("failed to mmap keyboard keymap");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (seat->kbd.xkb_compose_state != NULL) {
|
if (seat->kbd.xkb_compose_state != NULL) {
|
||||||
xkb_compose_state_unref(seat->kbd.xkb_compose_state);
|
xkb_compose_state_unref(seat->kbd.xkb_compose_state);
|
||||||
|
|
@ -304,6 +309,9 @@ keyboard_enter(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
LOG_DBG("%s: keyboard_enter: keyboard=%p, serial=%u, surface=%p",
|
LOG_DBG("%s: keyboard_enter: keyboard=%p, serial=%u, surface=%p",
|
||||||
seat->name, wl_keyboard, serial, surface);
|
seat->name, wl_keyboard, serial, surface);
|
||||||
|
|
||||||
|
if (seat->kbd.xkb == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
term_kbd_focus_in(term);
|
term_kbd_focus_in(term);
|
||||||
seat->kbd_focus = term;
|
seat->kbd_focus = term;
|
||||||
seat->kbd.serial = serial;
|
seat->kbd.serial = serial;
|
||||||
|
|
@ -360,6 +368,9 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
LOG_DBG("keyboard_leave: keyboard=%p, serial=%u, surface=%p",
|
LOG_DBG("keyboard_leave: keyboard=%p, serial=%u, surface=%p",
|
||||||
wl_keyboard, serial, surface);
|
wl_keyboard, serial, surface);
|
||||||
|
|
||||||
|
if (seat->kbd.xkb == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
seat->kbd_focus == NULL ||
|
seat->kbd_focus == NULL ||
|
||||||
surface == NULL || /* Seen on Sway 1.2 */
|
surface == NULL || /* Seen on Sway 1.2 */
|
||||||
|
|
@ -511,6 +522,9 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
struct seat *seat = data;
|
struct seat *seat = data;
|
||||||
struct terminal *term = seat->kbd_focus;
|
struct terminal *term = seat->kbd_focus;
|
||||||
|
|
||||||
|
if (seat->kbd.xkb == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
assert(term != NULL);
|
assert(term != NULL);
|
||||||
|
|
||||||
const xkb_mod_mask_t ctrl = 1 << seat->kbd.mod_ctrl;
|
const xkb_mod_mask_t ctrl = 1 << seat->kbd.mod_ctrl;
|
||||||
|
|
@ -734,6 +748,9 @@ keyboard_modifiers(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
LOG_DBG("modifiers: depressed=0x%x, latched=0x%x, locked=0x%x, group=%u",
|
LOG_DBG("modifiers: depressed=0x%x, latched=0x%x, locked=0x%x, group=%u",
|
||||||
mods_depressed, mods_latched, mods_locked, group);
|
mods_depressed, mods_latched, mods_locked, group);
|
||||||
|
|
||||||
|
if (seat->kbd.xkb == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
xkb_state_update_mask(
|
xkb_state_update_mask(
|
||||||
seat->kbd.xkb_state, mods_depressed, mods_latched, mods_locked, 0, 0, group);
|
seat->kbd.xkb_state, mods_depressed, mods_latched, mods_locked, 0, 0, group);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue