[hackers] [dwm][PATCH] fix lost focus issues when current window is fullscreen

From: <soeren_AT_soeren-tempel.net>
Date: Tue, 26 Jul 2016 14:15:36 +0200

From: Sören Tempel <soeren+git_AT_soeren-tempel.net>

If your current window is in fullscreen mode than you are able to
trigger a few cases where the current window focus is lost. For instance
when your current window is in fullscreen mode and you spawn a new
window (e.g. using dmenu) the new window will be focused but you can't
see it because the previous window is still in fullscreen mode.

For instance if you run mpv --fullscreen somevideo.mkv, invoke dmenu
afterwards using Alt+P and start a terminal emulator than you can't see
your terminal emulator window even though it is now the current window.

This patch attempts to fix these edge cases by either not allowing
certain actions when the current window is fullscreen or by
deactivating the fullscreen mode before performing certain operations.
---
 dwm.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/dwm.c b/dwm.c
index b2bc9bd..ea7b297 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -849,7 +849,7 @@ focusstack(const Arg *arg)
 {
 	Client *c = NULL, *i;
 
-	if (!selmon->sel)
+	if (!selmon->sel || selmon->sel->isfullscreen)
 		return;
 	if (arg->i > 0) {
 		for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
_AT_@ -1034,10 +1034,13 @@ killclient(const Arg *arg)
 void
 manage(Window w, XWindowAttributes *wa)
 {
-	Client *c, *t = NULL;
+	Client *sc, *c, *t = NULL;
 	Window trans = None;
 	XWindowChanges wc;
 
+	if ((sc = selmon->sel) && sc->isfullscreen)
+		setfullscreen(sc, False);
+
 	c = ecalloc(1, sizeof(Client));
 	c->win = w;
 	/* geometry */
_AT_@ -2030,6 +2033,11 @@ updatewmhints(Client *c)
 void
 view(const Arg *arg)
 {
+	Client *c;
+
+	if ((c = selmon->sel) && c->isfullscreen)
+		setfullscreen(c, False);
+
 	if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
 		return;
 	selmon->seltags ^= 1; /* toggle sel tagset */
_AT_@ -2110,6 +2118,9 @@ zoom(const Arg *arg)
 {
 	Client *c = selmon->sel;
 
+	if (c && c->isfullscreen)
+		setfullscreen(c, False);
+
 	if (!selmon->lt[selmon->sellt]->arrange
 	|| (selmon->sel && selmon->sel->isfloating))
 		return;
-- 
2.9.1
Received on Tue Jul 26 2016 - 14:15:36 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 26 2016 - 14:24:14 CEST