aboutsummaryrefslogtreecommitdiffstats
path: root/dwm-fullscreenhook-6.8.diff
blob: 9d267c30f8063b72797c28b6d50819564b3c4e60 (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
From 8b2c41af886b758126c7738fbd302fc1dfcc3172 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 fullscreen window on the root
 window

Set _DWM_FULLSCREEN on the root window to the window id of the client
that is fullscreen and clear it when the client exits, so a compositor,
notification daemon or GameMode helper can react without scanning every
window. Assumes one fullscreen client at a time.
---
 dwm.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/dwm.c b/dwm.c
index 53b393e..1868c5c 100644
--- a/dwm.c
+++ b/dwm.c
@@ -258,7 +258,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;
@@ -1492,9 +1492,12 @@ setfullscreen(Client *c, int fullscreen)
 		c->isfloating = 1;
 		resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
 		XRaiseWindow(dpy, c->win);
+		XChangeProperty(dpy, root, dwmfullscreen, XA_WINDOW, 32,
+			PropModeReplace, (unsigned char *)&c->win, 1);
 	} else if (!fullscreen && c->isfullscreen){
 		XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
 			PropModeReplace, (unsigned char*)0, 0);
+		XDeleteProperty(dpy, root, dwmfullscreen);
 		c->isfullscreen = 0;
 		c->isfloating = c->oldstate;
 		c->bw = c->oldbw;
@@ -1579,6 +1582,7 @@ 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);
 	/* init cursors */
 	cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
 	cursor[CurResize] = drw_cur_create(drw, XC_sizing);
@@ -1783,6 +1787,8 @@ unmanage(Client *c, int destroyed)
 
 	detach(c);
 	detachstack(c);
+	if (c->isfullscreen)
+		XDeleteProperty(dpy, root, dwmfullscreen);
 	if (!destroyed) {
 		wc.border_width = c->oldbw;
 		XGrabServer(dpy); /* avoid race conditions */
-- 
2.55.0