Keyboard: ignore >32 simultaneous key presses

wlroots implements this behavior with its key press tracking but
continues to forward the events to the compositor. Matching the wlroots
behavior here seems like the best way to avoid strange edge cases and
this is unlikely to ever be an annoying limit in practice.

Also take this oppurtunity to finally refactor away the hasMapping()
function in a way that doesn't sacrifice correctness even when hitting
this 32 key press limit.
This commit is contained in:
Isaac Freund
2024-02-19 11:33:38 +01:00
parent e1970e4d52
commit ec9a1b4303
2 changed files with 27 additions and 37 deletions

View File

@ -355,25 +355,6 @@ pub fn enterMode(self: *Self, mode_id: u32) void {
}
}
/// Is there a user-defined mapping for passed keycode, modifiers and keyboard state?
pub fn hasMapping(
self: *Self,
keycode: xkb.Keycode,
modifiers: wlr.Keyboard.ModifierMask,
released: bool,
xkb_state: *xkb.State,
) bool {
const modes = &server.config.modes;
for (modes.items[self.mode_id].mappings.items) |*mapping| {
if (mapping.match(keycode, modifiers, released, xkb_state, .no_translate) or
mapping.match(keycode, modifiers, released, xkb_state, .translate))
{
return true;
}
}
return false;
}
/// Handle any user-defined mapping for passed keycode, modifiers and keyboard state
/// Returns true if a mapping was run
pub fn handleMapping(