dwl-patches/patches/passthrough/passthrough.patch
2024-06-22 22:36:54 +08:00

83 lines
2.6 KiB
Diff

From 26dcd6a7aa8cb061a48c2233fe588f4426acb302 Mon Sep 17 00:00:00 2001
From: choc <notchoc@proton.me>
Date: Mon, 2 Jan 2023 13:00:29 +0800
Subject: [PATCH] passthrough: allow pausing keybind handling
allows for bitcarrying-esque control of nested instances
---
config.def.h | 4 ++++
dwl.c | 14 ++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/config.def.h b/config.def.h
index a784eb4..2913c82 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,6 +20,9 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* logging */
static int log_level = WLR_ERROR;
+/* passthrough */
+static int allow_passthru = 0;
+
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
/* examples: */
@@ -154,6 +157,7 @@ static const Key keys[] = {
TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6),
TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7),
TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8),
+ { WLR_MODIFIER_ALT|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT, XKB_KEY_Escape, togglepassthru, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, quit, {0} },
/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
diff --git a/dwl.c b/dwl.c
index d48bf40..0f8cad0 100644
--- a/dwl.c
+++ b/dwl.c
@@ -338,6 +338,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
+static void togglepassthru(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);
@@ -619,6 +620,11 @@ buttonpress(struct wl_listener *listener, void *data)
for (b = buttons; b < END(buttons); b++) {
if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
event->button == b->button && b->func) {
+ if (allow_passthru) {
+ if (b->func != togglepassthru) continue;
+ b->func(&b->arg);
+ break;
+ }
b->func(&b->arg);
return;
}
@@ -1506,6 +1512,8 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
for (k = keys; k < END(keys); k++) {
if (CLEANMASK(mods) == CLEANMASK(k->mod)
&& sym == k->keysym && k->func) {
+ if (allow_passthru && k->func != togglepassthru)
+ continue;
k->func(&k->arg);
return 1;
}
@@ -2675,6 +2683,12 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen);
}
+void
+togglepassthru(const Arg *arg)
+{
+ allow_passthru = !allow_passthru;
+}
+
void
toggletag(const Arg *arg)
{
--
2.43.0