aboutsummaryrefslogtreecommitdiff
path: root/url-mode.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2025-01-27 09:51:03 +0000
committerDaniel Eklöf <daniel@ekloef.se>2025-01-27 11:31:40 +0000
commit8d6f0d0583a1cb7c245ff54ec472a03ebcdb6949 (patch)
treeb532ad7ac6db0738c01ce6ddb8e646f121441d9d /url-mode.c
parentforgejo: application -> application(s) (diff)
key-bindings: try all bindings in translated mode before matching untranslated, and then finally raw
When trying to match key bindings, we do three types of matching: * Match the _translated_ symbol (e.g. Control+C) * Match the _untranslated_ symbol (e.g. Control+Shift+c) * Match raw keyboard codes This was done for *each* key binding. This meant we sometimes matched a keybinding in raw mode, even though there was a translated/untranslated binding that would match it too. All depending on the internal order of the key binding list. This patch changes it, so that we first try all bindings in translated mode, then all bindings in untranslated mode, and finally all bindings in raw mode. Closes #1929
Diffstat (limited to 'url-mode.c')
-rw-r--r--url-mode.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/url-mode.c b/url-mode.c
index 20c9820b..cca7bd22 100644
--- a/url-mode.c
+++ b/url-mode.c
@@ -178,11 +178,14 @@ urls_input(struct seat *seat, struct terminal *term,
const xkb_keysym_t *raw_syms, size_t raw_count,
uint32_t serial)
{
- /* Key bindings */
+ /*
+ * Key bindings
+ */
+
+ /* Match translated symbol */
tll_foreach(bindings->url, it) {
const struct key_binding *bind = &it->item;
- /* Match translated symbol */
if (bind->k.sym == sym &&
bind->mods == (mods & ~consumed))
{
@@ -190,6 +193,11 @@ urls_input(struct seat *seat, struct terminal *term,
return;
}
+ }
+
+ /* Match untranslated symbols */
+ tll_foreach(bindings->url, it) {
+ const struct key_binding *bind = &it->item;
if (bind->mods != mods)
continue;
@@ -199,6 +207,13 @@ urls_input(struct seat *seat, struct terminal *term,
return;
}
}
+ }
+
+ /* Match raw key code */
+ tll_foreach(bindings->url, it) {
+ const struct key_binding *bind = &it->item;
+ if (bind->mods != mods)
+ continue;
/* Match raw key code */
tll_foreach(bind->k.key_codes, code) {