From 6d30e7d15de49ba531cd8f8cd99c356d7f1ca0fc Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 18 Mar 2020 14:29:34 +0100 Subject: 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). --- search.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'search.c') diff --git a/search.c b/search.c index 98ad64eb..35d1be0f 100644 --- a/search.c +++ b/search.c @@ -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 */ -- cgit v1.3