Modified logic of press_repeat_release patch so that an unmodified keybinding with default values for the new flags will behave as it does in vanilla, while keybindings with customized flags will function as expected

This commit is contained in:
Micah N Gorrell 2024-03-27 16:27:59 -06:00
parent c567df584f
commit d5f6fbd853

View File

@ -1,7 +1,7 @@
From aee1dc3e9ca4d8deec5432d0c64921af6e301ecd Mon Sep 17 00:00:00 2001
From: Micah N Gorrell <m@minego.net>
Date: Wed, 27 Mar 2024 15:59:50 -0600
Subject: [PATCH] onpress, onrepeat, onrelease
Subject: [PATCH 1/2] onpress, onrepeat, onrelease
---
dwl.c | 18 ++++++++++++------
@ -74,3 +74,35 @@ index 5867b0c..43bbf0c 100644
--
2.44.0
From 1875bb171c9b0cd2fb03bb7e6c3fb400e33eeaf1 Mon Sep 17 00:00:00 2001
From: Micah N Gorrell <m@minego.net>
Date: Wed, 27 Mar 2024 16:26:52 -0600
Subject: [PATCH 2/2] Modified logic so that an unmodified keybinding with
default values for the new flags will behave as it does in vanilla, while
keybindings with customized flags will function as expected
---
dwl.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index 43bbf0c..55e7a40 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1443,7 +1443,11 @@ keybinding(uint32_t mods, xkb_keysym_t sym, int on_press, int on_repeat, int on_
for (k = keys; k < END(keys); k++) {
if (CLEANMASK(mods) == CLEANMASK(k->mod)
&& sym == k->keysym && k->func) {
- if ((on_press && k->on_press) || (on_repeat && k->on_repeat) || (on_release && k->on_release)) {
+ if ((k->on_press == 0 && k->on_repeat == 0 && k->on_release == 0) ||
+ (on_press && k->on_press) ||
+ (on_repeat && k->on_repeat) ||
+ (on_release && k->on_release)
+ ) {
k->func(&k->arg);
return 1;
}
--
2.44.0