aboutsummaryrefslogtreecommitdiffstats
path: root/dwm-fullscreenhook-6.8.diff
blob: f90def66b8acf0fbb8520a30d9d0ca26f5596e41 (plain) (blame)
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
From 70197161511b1504a6d6d655a288d2d922938a0f Mon Sep 17 00:00:00 2001
From: Daniel Guihot <daniel@guihot.net>
Date: Wed, 16 Sep 2026 05:09:22 +1000
Subject: [PATCH] fullscreenhook: publish the active fullscreen window

Set _DWM_FULLSCREEN on the root window to the selected fullscreen
client, and clear it when the selected client is not fullscreen.
Update the property on focus and fullscreen changes so it remains
correct across tags, monitors, client exits, and multiple fullscreen
clients.
---
 dwm.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/dwm.c b/dwm.c
index 53b393e..d1cb48c 100644
--- a/dwm.c
+++ b/dwm.c
@@ -199,6 +199,7 @@ static void sendmon(Client *c, Monitor *m);
 static void setclientstate(Client *c, long state);
 static void setfocus(Client *c);
 static void setfullscreen(Client *c, int fullscreen);
+static void setfullscreenprop(Client *c);
 static void setlayout(const Arg *arg);
 static void setmfact(const Arg *arg);
 static void setup(void);
@@ -258,7 +259,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
 	[PropertyNotify] = propertynotify,
 	[UnmapNotify] = unmapnotify
 };
-static Atom wmatom[WMLast], netatom[NetLast];
+static Atom wmatom[WMLast], netatom[NetLast], dwmfullscreen;
 static int running = 1;
 static Cur *cursor[CurLast];
 static Clr **scheme;
@@ -807,6 +808,7 @@ focus(Client *c)
 		XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
 	}
 	selmon->sel = c;
+	setfullscreenprop(c);
 	drawbars();
 }
 
@@ -1505,6 +1507,18 @@ setfullscreen(Client *c, int fullscreen)
 		resizeclient(c, c->x, c->y, c->w, c->h);
 		arrange(c->mon);
 	}
+	if (c == selmon->sel)
+		setfullscreenprop(c);
+}
+
+void
+setfullscreenprop(Client *c)
+{
+	if (c && c->isfullscreen)
+		XChangeProperty(dpy, root, dwmfullscreen, XA_WINDOW, 32,
+			PropModeReplace, (unsigned char *)&c->win, 1);
+	else
+		XDeleteProperty(dpy, root, dwmfullscreen);
 }
 
 void
@@ -1579,6 +1593,8 @@ setup(void)
 	netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
 	netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
 	netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
+	dwmfullscreen = XInternAtom(dpy, "_DWM_FULLSCREEN", False);
+	XDeleteProperty(dpy, root, dwmfullscreen);
 	/* init cursors */
 	cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
 	cursor[CurResize] = drw_cur_create(drw, XC_sizing);
-- 
2.55.0