mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
keyboard: fallback on raw keysyms for bindings
When looking up keybinds, if the translated keysyms (based on the keymap for the keyboard) do not match a defined keybind, try raw keysyms (as if there were no modifier translation). This allows a user to define for example keybind with "S-1" rather than "S-exclam". It also supports "W-S-Tab". Fixes: issues #163 #365 #992
This commit is contained in:
parent
8686023b0f
commit
c6e2f667d3
1 changed files with 17 additions and 0 deletions
|
|
@ -141,6 +141,17 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
|||
translated.nr_syms = xkb_state_key_get_syms(wlr_keyboard->xkb_state,
|
||||
keycode, &translated.syms);
|
||||
|
||||
/*
|
||||
* Get keysyms from the keyboard as if there was no modifier
|
||||
* translations. For example, get Shift+1 rather than Shift+! (with US
|
||||
* keyboard layout).
|
||||
*/
|
||||
struct keysyms raw = { 0 };
|
||||
xkb_layout_index_t layout_index =
|
||||
xkb_state_key_get_layout(wlr_keyboard->xkb_state, keycode);
|
||||
raw.nr_syms = xkb_keymap_key_get_syms_by_level(wlr_keyboard->keymap,
|
||||
keycode, layout_index, 0, &raw.syms);
|
||||
|
||||
bool handled = false;
|
||||
|
||||
key_state_set_pressed(event->keycode,
|
||||
|
|
@ -246,6 +257,12 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
|||
for (int i = 0; i < translated.nr_syms; i++) {
|
||||
handled |= handle_keybinding(server, modifiers, translated.syms[i]);
|
||||
}
|
||||
if (handled) {
|
||||
goto out;
|
||||
}
|
||||
for (int i = 0; i < raw.nr_syms; i++) {
|
||||
handled |= handle_keybinding(server, modifiers, raw.syms[i]);
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue