From 1e63dddb89a27de702fced65d7b6ba3b39812bb9 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 19 Mar 2022 18:59:15 +0100 Subject: input: don’t allow non-significant modifiers when matching untranslated symbols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- url-mode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'url-mode.c') diff --git a/url-mode.c b/url-mode.c index 350bdf25..6625e99a 100644 --- a/url-mode.c +++ b/url-mode.c @@ -119,22 +119,28 @@ activate_url(struct seat *seat, struct terminal *term, const struct url *url) void urls_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) { + 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; + /* Key bindings */ tll_foreach(seat->kbd.bindings.url, it) { const struct key_binding *bind = &it->item; /* Match translated symbol */ if (bind->k.sym == sym && - bind->mods == (mods & ~consumed)) + bind->mods == (bind_mods & ~bind_consumed)) { execute_binding(seat, term, bind, serial); return; } - if (bind->mods != mods) + if (bind->mods != bind_mods || bind_mods != (mods & ~locked)) continue; for (size_t i = 0; i < raw_count; i++) { -- cgit v1.3