input: bind key bindings to raw key codes too

Before, when looking for a matching user key binding, we only
matched *symbols*.

This means that the physical keys that generate a specific key binding
is layout dependent. What's worse, it may not even be possible to
generate the key binding at all.

Russian is one such layout, where all the "normal" (us) symbols are
replaced.

By using raw key codes, we can get around this - the key code has a
direct mapping to the physical key.

However, matching raw key codes **only** doesn't always make sense
either. For now, match **both** symbols _and_ key codes. Symbols take
precedence.

TODO: we might have to make this configurable _per binding_.

Note: 'search' mode still uses mostly hardcoded shortcuts that still
have this problem (i.e. ctrl+g doesn't work with a russian layout).
This commit is contained in:
Daniel Eklöf 2020-03-18 14:29:34 +01:00
parent fb5ab022de
commit 6d30e7d15d
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 61 additions and 1 deletions

View file

@ -430,10 +430,19 @@ search_input(struct terminal *term, uint32_t key, xkb_keysym_t sym,
* User configurable bindings
*/
tll_foreach(term->wl->kbd.bindings.search, it) {
/* Match symbol */
if (it->item.mods == mods && it->item.sym == sym) {
input_execute_binding(term, it->item.action, serial);
return;
}
/* Match raw key code */
tll_foreach(it->item.key_codes, code) {
if (code->item == key) {
input_execute_binding(term, it->item.action, serial);
return;
}
}
}
/* Cancel search */