seat: NULL-check on keyboard.modifiers event

It can be sent before keyboard.keymap (for example
when running swaylock from a different tty), in
which case the xkb state isn't initialized yet.
This commit is contained in:
tiosgz 2022-02-10 08:32:08 +00:00 committed by Simon Ser
parent 2f2173808a
commit cdc057f09a

4
seat.c
View File

@ -86,6 +86,10 @@ static void keyboard_modifiers(void *data, struct wl_keyboard *wl_keyboard,
uint32_t mods_locked, uint32_t group) { uint32_t mods_locked, uint32_t group) {
struct swaylock_seat *seat = data; struct swaylock_seat *seat = data;
struct swaylock_state *state = seat->state; struct swaylock_state *state = seat->state;
if (state->xkb.state == NULL) {
return;
}
int layout_same = xkb_state_layout_index_is_active(state->xkb.state, int layout_same = xkb_state_layout_index_is_active(state->xkb.state,
group, XKB_STATE_LAYOUT_EFFECTIVE); group, XKB_STATE_LAYOUT_EFFECTIVE);
if (!layout_same) { if (!layout_same) {