aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <mail@isaacfreund.com>2023-02-28 14:40:10 +0100
committerIsaac Freund <mail@isaacfreund.com>2023-02-28 14:40:10 +0100
commit06cb76f937e15c1830e606c892dbf64601345201 (patch)
tree18b9cc1c078426e476ecce5776ab023e15e2c300
parentc0c08ab91969e17823163f946be1e3856a54ba96 (diff)
downloadriver-06cb76f937e15c1830e606c892dbf64601345201.tar.gz
river-06cb76f937e15c1830e606c892dbf64601345201.tar.xz
Keyboard: fix keyboard-layout mapping crash
-rw-r--r--river/Keyboard.zig5
1 files changed, 4 insertions, 1 deletions
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