diff options
| author | Daniel Guihot | 2026-09-16 05:22:42 +1000 |
|---|---|---|
| committer | Daniel Guihot | 2026-09-16 05:22:42 +1000 |
| commit | 572fae56b30e86c686b61aa1e31ca9d0803cf313 (patch) | |
| tree | 643e205ea2f9ed49fbeeb1c87e3d7973d326c450 | |
| download | dwm-focusguard-572fae56b30e86c686b61aa1e31ca9d0803cf313.tar.gz dwm-focusguard-572fae56b30e86c686b61aa1e31ca9d0803cf313.zip | |
dwm 6.8 focusguard patch
| -rw-r--r-- | README.md | 32 | ||||
| -rw-r--r-- | dwm-focusguard-6.8.diff | 53 |
2 files changed, 85 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..471fb86 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# focusguard + +## Description + +This patch keeps focus on a fullscreen client when a new window appears. It +applies to dwm 6.8. + +`manage()` calls `focus(NULL)` for every new client on the selected monitor, +so Steam update dialogs, chat windows and notifications pull focus off a +running fullscreen game. Many games then drop fullscreen. With this patch the +fullscreen client stays selected and focused. The new client is still +attached, arranged and mapped, and can be reached after the game leaves +fullscreen or by switching tags. + +## Configuration + +The patch uses the existing `lockfullscreen` option in `config.h`. Set it to +0 to disable the behaviour. No new options are added. + +## Testing + +Applies and builds against dwm 6.8. Runtime tested under Xvfb: with a +fullscreen client focused, a new window no longer becomes +`_NET_ACTIVE_WINDOW`. + +## Download + +* [dwm-focusguard-6.8.diff](dwm-focusguard-6.8.diff) + +## Author + +* Daniel Guihot - [daniel@guihot.net](mailto:daniel@guihot.net) diff --git a/dwm-focusguard-6.8.diff b/dwm-focusguard-6.8.diff new file mode 100644 index 0000000..1ad7f72 --- /dev/null +++ b/dwm-focusguard-6.8.diff @@ -0,0 +1,53 @@ +From a4409c4cb987e486501043e5c1de34833ce15a14 Mon Sep 17 00:00:00 2001 +From: Daniel Guihot <daniel@guihot.net> +Date: Wed, 16 Sep 2026 05:06:53 +1000 +Subject: [PATCH] focusguard: keep focus on fullscreen clients when windows + spawn + +manage() focuses every new client on the selected monitor, which pulls +focus off a running fullscreen game and makes many games drop +fullscreen. Keep the fullscreen client selected and focused while +lockfullscreen is set. The new client is still attached, arranged and +mapped, and can be reached after the game leaves fullscreen. +--- + dwm.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/dwm.c b/dwm.c +index 53b393e..0654ea2 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -1031,7 +1031,7 @@ killclient(const Arg *arg) + void + manage(Window w, XWindowAttributes *wa) + { +- Client *c, *t = NULL; ++ Client *c, *t = NULL, *fs = NULL; + Window trans = None; + XWindowChanges wc; + +@@ -1080,12 +1080,18 @@ manage(Window w, XWindowAttributes *wa) + (unsigned char *) &(c->win), 1); + XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ + setclientstate(c, NormalState); +- if (c->mon == selmon) ++ if (c->mon == selmon && lockfullscreen && selmon->sel ++ && selmon->sel->isfullscreen) ++ fs = selmon->sel; ++ if (c->mon == selmon && !fs) + unfocus(selmon->sel, 0); +- c->mon->sel = c; ++ c->mon->sel = fs ? fs : c; + arrange(c->mon); + XMapWindow(dpy, c->win); +- focus(NULL); ++ if (fs) ++ focus(fs); ++ else ++ focus(NULL); + } + + void +-- +2.55.0 + |
