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
|
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
|