aboutsummaryrefslogtreecommitdiff
path: root/search.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-03-19 17:59:15 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-03-20 12:29:29 +0000
commit1e63dddb89a27de702fced65d7b6ba3b39812bb9 (patch)
treea8d05fbefb5cd35d977df06c4b8a197d516f2011 /search.c
parentchar32: only include stdc-predef.h if it is available (diff)
input: don’t allow non-significant modifiers when matching untranslated symbols
When matching “untranslated” bindings (by matching the base symbol of the key, e.g. ctrl+shift+2 in US layout), require that no non-significant modifiers are active. This fixes an issue where AltGr was “ignored”, and would cause certain combinations to match a key binding. Example: ctrl+altgr+0, on many European layouts matched against the default ctrl+0 (reset the font size), instead of emitting ^] To make this work, we now need to filter out “locked” modifiers (e.g. NumLock and CapsLock). Otherwise having e.g. NumLock active would prevent *all* untranslated matching to fail. Closes #983
Diffstat (limited to 'search.c')
-rw-r--r--search.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/search.c b/search.c
index 6251c697..b422d957 100644
--- a/search.c
+++ b/search.c
@@ -822,11 +822,16 @@ execute_binding(struct seat *seat, struct terminal *term,
void
search_input(struct seat *seat, struct terminal *term, uint32_t key,
xkb_keysym_t sym, xkb_mod_mask_t mods, xkb_mod_mask_t consumed,
+ xkb_mod_mask_t locked,
const xkb_keysym_t *raw_syms, size_t raw_count,
uint32_t serial)
{
LOG_DBG("search: input: sym=%d/0x%x, mods=0x%08x", sym, sym, mods);
+ const xkb_mod_mask_t bind_mods =
+ mods & seat->kbd.bind_significant & ~locked;
+ const xkb_mod_mask_t bind_consumed =
+ consumed & seat->kbd.bind_significant & ~locked;
enum xkb_compose_status compose_status = seat->kbd.xkb_compose_state != NULL
? xkb_compose_state_get_status(seat->kbd.xkb_compose_state)
: XKB_COMPOSE_NOTHING;
@@ -840,7 +845,7 @@ search_input(struct seat *seat, struct terminal *term, uint32_t key,
/* Match translated symbol */
if (bind->k.sym == sym &&
- bind->mods == (mods & ~consumed)) {
+ bind->mods == (bind_mods & ~bind_consumed)) {
if (execute_binding(seat, term, bind, serial,
&update_search_result, &redraw))
@@ -850,7 +855,7 @@ search_input(struct seat *seat, struct terminal *term, uint32_t key,
return;
}
- if (bind->mods != mods)
+ if (bind->mods != bind_mods || bind_mods != (mods & ~locked))
continue;
/* Match untranslated symbols */