From 6e536e7ed8f1de2615fa323123ddb2b06a45a179 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 4 Mar 2022 17:54:19 +0100 Subject: input: get_current_modifiers(): don’t crash if seat has no keyboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #963 --- input.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'input.c') diff --git a/input.c b/input.c index f402fa3d..047d7c86 100644 --- a/input.c +++ b/input.c @@ -1010,14 +1010,23 @@ get_current_modifiers(const struct seat *seat, xkb_mod_mask_t *effective, xkb_mod_mask_t *consumed, uint32_t key) { - if (effective != NULL) { - *effective = xkb_state_serialize_mods( - seat->kbd.xkb_state, XKB_STATE_MODS_EFFECTIVE); + if (unlikely(seat->kbd.xkb_state == NULL)) { + if (effective != NULL) + *effective = 0; + if (consumed != NULL) + *consumed = 0; } - if (consumed != NULL) { - *consumed = xkb_state_key_get_consumed_mods2( - seat->kbd.xkb_state, key, XKB_CONSUMED_MODE_XKB); + else { + if (effective != NULL) { + *effective = xkb_state_serialize_mods( + seat->kbd.xkb_state, XKB_STATE_MODS_EFFECTIVE); + } + + if (consumed != NULL) { + *consumed = xkb_state_key_get_consumed_mods2( + seat->kbd.xkb_state, key, XKB_CONSUMED_MODE_XKB); + } } } -- cgit v1.3