aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <mail@isaacfreund.com>2024-01-11 16:55:02 -0600
committerIsaac Freund <mail@isaacfreund.com>2024-01-11 16:55:02 -0600
commitc9838c31b6a4e01f990f73b7cc4bc28bf8b7ff25 (patch)
tree20b502914349bf0714eb0b70b099fe41d095457f
parentec8f57e704f802eaa98275785f66618a7652fd11 (diff)
downloadriver-c9838c31b6a4e01f990f73b7cc4bc28bf8b7ff25.tar.gz
river-c9838c31b6a4e01f990f73b7cc4bc28bf8b7ff25.tar.xz
Keyboard: don't send enter before keymap event
It's unclear if this is technically a violation of the protocol or not, but it makes little sense to do this and many clients in the wild crash if wl_keyboard.enter is sent before wl_keyboard.keymap.
-rw-r--r--river/Keyboard.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/river/Keyboard.zig b/river/Keyboard.zig
index 69c34b2..6d19023 100644
--- a/river/Keyboard.zig
+++ b/river/Keyboard.zig
@@ -75,8 +75,24 @@ pub fn deinit(self: *Self) void {
self.key.link.remove();
self.modifiers.link.remove();
+ const seat = self.device.seat;
+ const wlr_keyboard = self.device.wlr_device.toKeyboard();
+
self.device.deinit();
+ // If the currently active keyboard of a seat is destroyed we need to set
+ // a new active keyboard. Otherwise wlroots may send an enter event without
+ // first having sent a keymap event if Seat.keyboardNotifyEnter() is called
+ // before a new active keyboard is set.
+ if (seat.wlr_seat.getKeyboard() == wlr_keyboard) {
+ var it = server.input_manager.devices.iterator(.forward);
+ while (it.next()) |device| {
+ if (device.seat == seat and device.wlr_device.type == .keyboard) {
+ seat.wlr_seat.setKeyboard(device.wlr_device.toKeyboard());
+ }
+ }
+ }
+
self.* = undefined;
}