Keyboard: don't crash when coming from a different tty

It didn't occur to me that this is a completely valid case when a key
release event is received even though there was no press event known
to river.

(I've also just had this same crash on something else, but i don't
understand what the cause could be.)
This commit is contained in:
tiosgz 2024-02-19 08:48:16 +00:00
parent d1bb27038b
commit e1970e4d52

View File

@ -177,7 +177,10 @@ fn handleKey(listener: *wl.Listener(*wlr.Keyboard.event.Key), event: *wlr.Keyboa
const consumer: KeyConsumer = blk: { const consumer: KeyConsumer = blk: {
// Decision is made on press; release only follows it // Decision is made on press; release only follows it
if (released) break :blk self.pressed.remove(event.keycode).?; if (released) break :blk self.pressed.remove(event.keycode) orelse {
// This can happen for example when switching from a different tty
return;
};
if (self.device.seat.hasMapping(keycode, modifiers, released, xkb_state)) { if (self.device.seat.hasMapping(keycode, modifiers, released, xkb_state)) {
// The key must be added to the set of pressed keys with the correct consumer before // The key must be added to the set of pressed keys with the correct consumer before