fullscreen-compilation: better fix for client losing focus on exiting fullscreen

pull/74/head
bakkeby 3 years ago
parent cf9ea5ea3f
commit dca8b9be86

@ -1,4 +1,4 @@
From 979a7c2d77f7284247c025d9657d5ff4b4972236 Mon Sep 17 00:00:00 2001
From 4637d9b0d4a4e4ecd5560037247923c620f12973 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Sat, 5 Sep 2020 14:32:26 +0200
Subject: [PATCH] Compilation of fullscreen patches for dwm.
@ -26,8 +26,8 @@ This incorporates, and expands on, the following patches:
- losefullscreen
---
config.def.h | 4 +-
dwm.c | 183 ++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 148 insertions(+), 39 deletions(-)
dwm.c | 181 ++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 147 insertions(+), 38 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..5f28f2c 100644
@ -48,7 +48,7 @@ index 1c0b587..5f28f2c 100644
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
diff --git a/dwm.c b/dwm.c
index 4465af1..57f46eb 100644
index 4465af1..74307ad 100644
--- a/dwm.c
+++ b/dwm.c
@@ -93,6 +93,7 @@ struct Client {
@ -186,24 +186,7 @@ index 4465af1..57f46eb 100644
return;
restack(selmon);
ocx = c->x;
@@ -1284,7 +1295,15 @@ resizeclient(Client *c, int x, int y, int w, int h)
wc.border_width = c->bw;
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
- XSync(dpy, False);
+ if (c->fakefullscreen == 1)
+ /* Exception: if the client was in actual fullscreen and we exit out to fake fullscreen
+ * mode, then the focus would drift to whichever window is under the mouse cursor at the
+ * time. To avoid this we pass True to XSync which will make the X server disregard any
+ * other events in the queue thus cancelling the EnterNotify event that would otherwise
+ * have changed focus. */
+ XSync(dpy, True);
+ else
+ XSync(dpy, False);
}
void
@@ -1298,7 +1317,7 @@ resizemouse(const Arg *arg)
@@ -1298,7 +1309,7 @@ resizemouse(const Arg *arg)
if (!(c = selmon->sel))
return;
@ -212,7 +195,7 @@ index 4465af1..57f46eb 100644
return;
restack(selmon);
ocx = c->x;
@@ -1412,7 +1431,7 @@ sendmon(Client *c, Monitor *m)
@@ -1412,7 +1423,7 @@ sendmon(Client *c, Monitor *m)
{
if (c->mon == m)
return;
@ -221,13 +204,14 @@ index 4465af1..57f46eb 100644
detach(c);
detachstack(c);
c->mon = m;
@@ -1472,29 +1491,71 @@ setfocus(Client *c)
@@ -1472,29 +1483,79 @@ setfocus(Client *c)
void
setfullscreen(Client *c, int fullscreen)
{
- if (fullscreen && !c->isfullscreen) {
- XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
- PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
+ XEvent ev;
+ int savestate = 0, restorestate = 0, restorefakefullscreen = 0;
+
+ if ((c->fakefullscreen == 0 && fullscreen && !c->isfullscreen) // normal fullscreen
@ -305,6 +289,13 @@ index 4465af1..57f46eb 100644
resizeclient(c, c->x, c->y, c->w, c->h);
- arrange(c->mon);
- }
+
+ /* Exception: if the client was in actual fullscreen and we exit out to fake fullscreen
+ * mode, then the focus would sometimes drift to whichever window is under the mouse cursor
+ * at the time. To avoid this we ask X for all EnterNotify events and just ignore them.
+ */
+ if (!c->isfullscreen)
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
void

@ -1,4 +1,4 @@
From fb3713e426c42c45837f4a943cef2f496a1577e3 Mon Sep 17 00:00:00 2001
From 6fe4ab2ab8347f7b7288efbeb393593cc885b6a5 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 15 Sep 2020 08:34:59 +0200
Subject: [PATCH 2/2] Adding fake fullscreen compatible noborder patch
@ -8,7 +8,7 @@ Subject: [PATCH 2/2] Adding fake fullscreen compatible noborder patch
1 file changed, 9 insertions(+)
diff --git a/dwm.c b/dwm.c
index 5352547..0bf05cd 100644
index 74307ad..eaaf033 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1293,6 +1293,15 @@ resizeclient(Client *c, int x, int y, int w, int h)
@ -26,7 +26,7 @@ index 5352547..0bf05cd 100644
+ }
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
if (c->fakefullscreen == 1)
XSync(dpy, False);
--
2.19.1

@ -1,6 +1,6 @@
From 5186be6b513e23bb78ae18be5a68faf055f7a221 Mon Sep 17 00:00:00 2001
From 55cdcb33d04d6271ca720f8cb07b6820caac6a61 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 15 Sep 2020 09:21:16 +0200
Date: Wed, 12 May 2021 16:05:54 +0200
Subject: [PATCH 2/2] Adding fake fullscreen client rule
---
@ -26,7 +26,7 @@ index 5f28f2c..dd98367 100644
/* layout(s) */
diff --git a/dwm.c b/dwm.c
index 5352547..9c0b1f1 100644
index 74307ad..b6a64e4 100644
--- a/dwm.c
+++ b/dwm.c
@@ -139,6 +139,7 @@ typedef struct {

@ -1,4 +1,4 @@
From a87ffffc46d586a7835a7d390d2a7db16ddfea97 Mon Sep 17 00:00:00 2001
From 62f53f4025048b478bf9951f81742b3c6f65b09d Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Sat, 5 Sep 2020 18:24:28 +0200
Subject: [PATCH 2/2] Adding fullscreen-compilation compatible tagallmon patch
@ -22,7 +22,7 @@ index 5f28f2c..0d5456a 100644
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
diff --git a/dwm.c b/dwm.c
index ac03fbb..ae71d99 100644
index 74307ad..1e8c847 100644
--- a/dwm.c
+++ b/dwm.c
@@ -208,6 +208,7 @@ static void showhide(Client *c);
@ -33,7 +33,7 @@ index ac03fbb..ae71d99 100644
static void tagmon(const Arg *arg);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
@@ -1680,6 +1681,50 @@ tag(const Arg *arg)
@@ -1723,6 +1724,50 @@ tag(const Arg *arg)
}
}

@ -1,4 +1,4 @@
From b3233c74bf5b52030e8d12bb665761226ef976f1 Mon Sep 17 00:00:00 2001
From 69e0705d78f3e3691ae5bacc199ca61bcaf04ea4 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Sat, 5 Sep 2020 18:22:35 +0200
Subject: [PATCH 2/2] Adding fullscreen-compilation compatible tagswapmon patch
@ -22,7 +22,7 @@ index 5f28f2c..c47cddb 100644
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
diff --git a/dwm.c b/dwm.c
index ac03fbb..471d66e 100644
index 74307ad..90dff7d 100644
--- a/dwm.c
+++ b/dwm.c
@@ -209,6 +209,7 @@ static void sigchld(int unused);
@ -33,7 +33,7 @@ index ac03fbb..471d66e 100644
static void tile(Monitor *);
static void togglebar(const Arg *arg);
static void togglefakefullscreen(const Arg *arg);
@@ -1698,6 +1699,71 @@ tagmon(const Arg *arg)
@@ -1741,6 +1742,71 @@ tagmon(const Arg *arg)
sendmon(c, dirtomon(arg->i));
}

Loading…
Cancel
Save