summaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
authorJohannes Herman <johannes.herman@gmail.com>2025-08-12 12:47:07 +0200
committerJohannes Herman <johannes.herman@gmail.com>2025-08-12 12:47:07 +0200
commitd5bc2bfd91fa4be16e47715eeb2721f26a57ddc2 (patch)
tree601409bd34c0a58b4174e726f594078b493923fe /dwl.c
parentc58369db1c313ca3d62c5765c1ca0cbd61a3892d (diff)
added chainkeys
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c23
1 files changed, 22 insertions, 1 deletions
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;
}