Keyboard: fix keyboard-layout mapping crash

This commit is contained in:
Isaac Freund 2023-02-28 14:40:10 +01:00
parent c0c08ab919
commit 06cb76f937
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11

View File

@ -85,7 +85,10 @@ fn handleKey(listener: *wl.Listener(*wlr.Keyboard.event.Key), event: *wlr.Keyboa
const modifiers = wlr_keyboard.getModifiers(); const modifiers = wlr_keyboard.getModifiers();
const released = event.state == .released; const released = event.state == .released;
const xkb_state = wlr_keyboard.xkb_state orelse return; // We must ref() the state here as a mapping could change the keyboard layout.
const xkb_state = (wlr_keyboard.xkb_state orelse return).ref();
defer xkb_state.unref();
const keysyms = xkb_state.keyGetSyms(keycode); const keysyms = xkb_state.keyGetSyms(keycode);
// Hide cursor when typing // Hide cursor when typing