From d5bc2bfd91fa4be16e47715eeb2721f26a57ddc2 Mon Sep 17 00:00:00 2001 From: Johannes Herman Date: Tue, 12 Aug 2025 12:47:07 +0200 Subject: added chainkeys --- dwl.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index 684491a..f8e9fef 100644 --- a/dwl.c +++ b/dwl.c @@ -156,6 +156,7 @@ struct Client { typedef struct { uint32_t mod; + int chain; xkb_keysym_t keysym; void (*func)(const Arg *); const Arg arg; @@ -396,6 +397,7 @@ static const char broken[] = "broken"; static pid_t child_pid = -1; static int locked; static void *exclusive_focus; +static int chainkey = -1; static struct wl_display *dpy; static struct wl_event_loop *event_loop; static struct wlr_backend *backend; @@ -1718,11 +1720,30 @@ keybinding(uint32_t mods, xkb_keysym_t sym) const Key *k; for (k = keys; k < END(keys); k++) { if (CLEANMASK(mods) == CLEANMASK(k->mod) - && sym == k->keysym && k->func) { + && sym == k->keysym + && chainkey == -1 + && k->chain == -1 + && k->func) { k->func(&k->arg); return 1; } + else if (sym == k->keysym + && chainkey != -1 + && k->chain == chainkey + && k->func) { + k->func(&k->arg); + chainkey = -1; + return 1; + } + else if (CLEANMASK(mods) == CLEANMASK(k->mod) + && k->chain == (int)sym + && chainkey == -1 + && k->func) { + chainkey = sym; + return 1; + } } + chainkey = -1; return 0; } -- cgit v1.2.3