From 70197161511b1504a6d6d655a288d2d922938a0f Mon Sep 17 00:00:00 2001 From: Daniel Guihot 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