Files
dwl-patches/patches/chainkeys/chainkeys.patch
T
2026-10-02 11:06:30 -07:00

75 lines
2.1 KiB
Diff

diff --git a/Makefile b/Makefile
index 8304245..836cb87 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \
DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
-Wno-unused-parameter -Wshadow -Wunused-macros -Werror=strict-prototypes \
-Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types \
- -Wfloat-conversion
+ -Wfloat-conversion -Wno-missing-field-initializers
# CFLAGS / LDFLAGS
PKGS = wayland-server xkbcommon libinput $(XLIBS)
diff --git a/dwl.c b/dwl.c
index 216deb5..af011ea 100644
--- a/dwl.c
+++ b/dwl.c
@@ -166,6 +166,7 @@ typedef struct {
xkb_keysym_t keysym;
void (*func)(const Arg *);
const Arg arg;
+ xkb_keysym_t chain;
} Key;
typedef struct {
@@ -378,6 +379,7 @@ static void zoom(const Arg *arg);
/* variables */
static pid_t child_pid = -1;
static int locked;
+static xkb_keysym_t chainkey = 0;
static Client *focused_client;
static struct wl_display *dpy;
static struct wl_event_loop *event_loop;
@@ -1735,9 +1737,21 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
* processing.
*/
const Key *k;
+ if (chainkey) {
+ for (k = keys; k < END(keys); k++) {
+ if (chainkey == k->keysym && sym == k->chain) {
+ chainkey = 0;
+ return k;
+ }
+ }
+ chainkey = 0;
+ return NULL;
+ }
for (k = keys; k < END(keys); k++) {
- if (CLEANMASK(mods) == CLEANMASK(k->mod) && sym == k->keysym && k->func)
+ if (CLEANMASK(mods) == CLEANMASK(k->mod) && sym == k->keysym && k->func) {
+ if (k->chain) chainkey = k->keysym;
return k;
+ }
}
return NULL;
}
@@ -1771,7 +1785,7 @@ keypress(struct wl_listener *listener, void *data)
const Key *key = keybinding(group->mods, group->keysyms[i]);
if (key) {
consumed[event->keycode] = 1;
- key->func(&key->arg);
+ if (!chainkey) key->func(&key->arg);
handled = 1;
break;
}
@@ -1827,7 +1841,7 @@ keyrepeat(void *data)
for (int i = 0; i < 2; i++) {
const Key *key = keybinding(group->mods, group->keysyms[i]);
if (key) {
- key->func(&key->arg);
+ if (!chainkey) key->func(&key->arg);
break;
}
}