summaryrefslogtreecommitdiffstats
path: root/dwl-patches/patches/disable-keybindings-on-fullscreen/disable-keybindings-on-fullscreen.patch
blob: 57a18e116ead33b66a4c164f5856d60494c4e3a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
From 2d6b845701091d3238774747c718df7fef135986 Mon Sep 17 00:00:00 2001
From: korei999 <ju7t1xe@gmail.com>
Date: Sun, 9 Feb 2025 14:59:33 +0200
Subject: [PATCH] disable keybindings on fullscreen

---
 dwl.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/dwl.c b/dwl.c
index ec4ca86..8c771e8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -282,6 +282,7 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data);
 static void destroysessionlock(struct wl_listener *listener, void *data);
 static void destroykeyboardgroup(struct wl_listener *listener, void *data);
 static Monitor *dirtomon(enum wlr_direction dir);
+static Client *firstfocused(void);
 static void focusclient(Client *c, int lift);
 static void focusmon(const Arg *arg);
 static void focusstack(const Arg *arg);
@@ -620,11 +621,15 @@ buttonpress(struct wl_listener *listener, void *data)
 	struct wlr_pointer_button_event *event = data;
 	struct wlr_keyboard *keyboard;
 	uint32_t mods;
-	Client *c;
+	Client *c, *focused;
 	const Button *b;
 
 	wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
 
+	focused = firstfocused();
+	if (focused && focused->isfullscreen)
+		goto skip_click;
+
 	switch (event->state) {
 	case WL_POINTER_BUTTON_STATE_PRESSED:
 		cursor_mode = CurPressed;
@@ -664,6 +669,7 @@ buttonpress(struct wl_listener *listener, void *data)
 	}
 	/* If the event wasn't handled by the compositor, notify the client with
 	 * pointer focus that a button press has occurred */
+skip_click:
 	wlr_seat_pointer_notify_button(seat,
 			event->time_msec, event->button, event->state);
 }
@@ -1393,6 +1399,13 @@ dirtomon(enum wlr_direction dir)
 	return selmon;
 }
 
+Client *
+firstfocused(void)
+{
+	Client *c = wl_container_of(fstack.next, c, flink);
+	return c;
+}
+
 void
 focusclient(Client *c, int lift)
 {
@@ -1607,10 +1620,18 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
 	 * processing keys, rather than passing them on to the client for its own
 	 * processing.
 	 */
+	Client *c = firstfocused();
 	const Key *k;
 	for (k = keys; k < END(keys); k++) {
 		if (CLEANMASK(mods) == CLEANMASK(k->mod)
 				&& sym == k->keysym && k->func) {
+			if (c && c->isfullscreen) {
+				if (k->func == togglefullscreen) {
+					k->func(&k->arg);
+					return 1;
+				}
+				return 0;
+			}
 			k->func(&k->arg);
 			return 1;
 		}
-- 
2.48.1