keyboard: fix virtual keyboard bug

Do no process virtual keyboard keycodes (just the keysyms).

Reproduce bug by issuing `wlrctl keyboard type xyz` and observe only 'x'
when 'xyz' was expected.

The 'y' and 'z' were matched in match_keybinding() in the keycode section and
returned keybinds for `XF86_AudioLowerVolume` and `XF86_AudioRaiseVolume`
respectively.

Fixes: #1367
This commit is contained in:
Johan Malm 2023-12-28 17:47:52 +00:00 committed by Consolatis
parent 7c59351774
commit e77dddbc59

View file

@ -154,8 +154,13 @@ match_keybinding_for_sym(struct server *server, uint32_t modifiers,
* the raw keysym fallback. * the raw keysym fallback.
*/ */
static struct keybind * static struct keybind *
match_keybinding(struct server *server, struct keyinfo *keyinfo) match_keybinding(struct server *server, struct keyinfo *keyinfo,
bool is_virtual)
{ {
if (is_virtual) {
goto process_syms;
}
/* First try keycodes */ /* First try keycodes */
struct keybind *keybind = match_keybinding_for_sym(server, struct keybind *keybind = match_keybinding_for_sym(server,
keyinfo->modifiers, XKB_KEY_NoSymbol, keyinfo->xkb_keycode); keyinfo->modifiers, XKB_KEY_NoSymbol, keyinfo->xkb_keycode);
@ -164,6 +169,7 @@ match_keybinding(struct server *server, struct keyinfo *keyinfo)
return keybind; return keybind;
} }
process_syms:
/* Then fall back to keysyms */ /* Then fall back to keysyms */
for (int i = 0; i < keyinfo->translated.nr_syms; i++) { for (int i = 0; i < keyinfo->translated.nr_syms; i++) {
keybind = match_keybinding_for_sym(server, keyinfo->modifiers, keybind = match_keybinding_for_sym(server, keyinfo->modifiers,
@ -424,7 +430,8 @@ handle_compositor_keybindings(struct keyboard *keyboard,
/* /*
* Handle compositor keybinds * Handle compositor keybinds
*/ */
struct keybind *keybind = match_keybinding(server, &keyinfo); struct keybind *keybind =
match_keybinding(server, &keyinfo, keyboard->is_virtual);
if (keybind) { if (keybind) {
/* /*
* Update key-state before action_run() because the action * Update key-state before action_run() because the action