From 06cb76f937e15c1830e606c892dbf64601345201 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 28 Feb 2023 14:40:10 +0100 Subject: [PATCH] Keyboard: fix keyboard-layout mapping crash --- river/Keyboard.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/river/Keyboard.zig b/river/Keyboard.zig index 55efde8..4b5afce 100644 --- a/river/Keyboard.zig +++ b/river/Keyboard.zig @@ -85,7 +85,10 @@ fn handleKey(listener: *wl.Listener(*wlr.Keyboard.event.Key), event: *wlr.Keyboa const modifiers = wlr_keyboard.getModifiers(); 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); // Hide cursor when typing