From a5b554761a8b376657be2a7e613b37fd5803920c Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 2 Mar 2021 17:50:06 +0100 Subject: input: repair key combos containing both explicit modifier and shifted symbol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a user-provided key combo contains both an explicit modifier, and the shifted symbol it produces, replace the symbol with its un-shifted version. Example: Control+Shift+U contains both ‘Shift’, and ‘U’, where ‘Shift’ is the modifier that shifts ‘u’ to ‘U’. Such modifiers are “consumed”, i.e. filtered out, when matching key combos. As such, Control+Shift+U will never trigger since we’ll never be able to match the consumed modifier ‘Shift’. The above combo can be written in two ways: - Control+U - Control+Shift+u To be able to detect that Control+Shift+U is an invalid combination, we need to check all *shifted* symbols for all key *codes*. Once we’ve detected a shifted symbol (and where it differs from the un-shifted symbol), we loop all modifier sets that produce the shift level where our shifted symbol is. For each such set, check if it intersects with the user-provided key combo’s modifier set. If there is an intersection, it means the user provided a key combo containing a modifier and symbol, such that the modifier is consumed when the symbol is produced. In this case, we replace the symbol with its un-shifted version. --- config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'config.c') diff --git a/config.c b/config.c index 927d9450..9babe8eb 100644 --- a/config.c +++ b/config.c @@ -1191,6 +1191,7 @@ parse_key_combos(struct config *conf, const char *combos, key_combo_list_t *key_ key++; /* Skip past the '+' */ } +#if 0 if (modifiers.shift && strlen(key) == 1 && (*key >= 'A' && *key <= 'Z')) { LOG_WARN( "%s:%d: [%s]: %s: %s: " @@ -1204,7 +1205,7 @@ parse_key_combos(struct config *conf, const char *combos, key_combo_list_t *key_ path, lineno, section, option, combo); *key = *key - 'A' + 'a'; } - +#endif /* Translate key name to symbol */ xkb_keysym_t sym = xkb_keysym_from_name(key, 0); if (sym == XKB_KEY_NoSymbol) { -- cgit v1.3