diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-07-14 06:52:11 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-07-14 06:52:11 +0000 |
| commit | 307eead98774af7d63d3d307cacacf11a21e09d8 (patch) | |
| tree | e61bca85fe1562ec8c8b9de5086b002e902052e9 /input.c | |
| parent | Merge branch 'merge-wl-surface-damage' (diff) | |
input: keyboard: detect failure to mmap keymap
Diffstat (limited to 'input.c')
| -rw-r--r-- | input.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -210,6 +210,11 @@ keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, 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"); + return; + } + if (seat->kbd.xkb_compose_state != NULL) { 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", seat->name, wl_keyboard, serial, surface); + if (seat->kbd.xkb == NULL) + return; + term_kbd_focus_in(term); seat->kbd_focus = term; 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", wl_keyboard, serial, surface); + if (seat->kbd.xkb == NULL) + return; + assert( seat->kbd_focus == NULL || 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 terminal *term = seat->kbd_focus; + if (seat->kbd.xkb == NULL) + return; + assert(term != NULL); 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", mods_depressed, mods_latched, mods_locked, group); + if (seat->kbd.xkb == NULL) + return; + xkb_state_update_mask( seat->kbd.xkb_state, mods_depressed, mods_latched, mods_locked, 0, 0, group); |
