focusedontop: better workaround for flicker on monocle layout ref. #31

pull/74/head
bakkeby 3 years ago
parent 4ed43fcab2
commit cf9ea5ea3f

@ -246,7 +246,7 @@ index 1d4475b..74bf95a 100644
2.19.1
From a61bdceea00104104efc35627823462674b1ddba Mon Sep 17 00:00:00 2001
From e43bceea3bbba454125baf82116e25a061bb5a8b Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Thu, 8 Oct 2020 19:38:56 +0200
Subject: [PATCH 3/3] focusedontop: allow the currently focused client to
@ -255,8 +255,8 @@ Subject: [PATCH 3/3] focusedontop: allow the currently focused client to
---
config.def.h | 16 +++++++++-------
dwm.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 51 insertions(+), 9 deletions(-)
dwm.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 56 insertions(+), 9 deletions(-)
diff --git a/config.def.h b/config.def.h
index dd003d0..7c0c27e 100644
@ -293,7 +293,7 @@ index dd003d0..7c0c27e 100644
/* layout(s) */
diff --git a/dwm.c b/dwm.c
index 74bf95a..e84bba1 100644
index 74bf95a..9869fa3 100644
--- a/dwm.c
+++ b/dwm.c
@@ -60,7 +60,7 @@
@ -339,7 +339,23 @@ index 74bf95a..e84bba1 100644
} else if (cme->message_type == netatom[NetActiveWindow]) {
if (c != selmon->sel && !c->isurgent)
seturgent(c, 1);
@@ -791,6 +797,8 @@ expose(XEvent *e)
@@ -764,6 +770,7 @@ enternotify(XEvent *e)
{
Client *c;
Monitor *m;
+ XEvent xev;
XCrossingEvent *ev = &e->xcrossing;
if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
@@ -776,6 +783,7 @@ enternotify(XEvent *e)
} else if (!c || c == selmon->sel)
return;
focus(c);
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &xev));
}
void
@@ -791,6 +799,8 @@ expose(XEvent *e)
void
focus(Client *c)
{
@ -348,7 +364,7 @@ index 74bf95a..e84bba1 100644
if (!c || !ISVISIBLE(c))
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
if (selmon->sel && selmon->sel != c)
@@ -805,6 +813,32 @@ focus(Client *c)
@@ -805,6 +815,31 @@ focus(Client *c)
grabbuttons(c, 1);
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
setfocus(c);
@ -376,12 +392,19 @@ index 74bf95a..e84bba1 100644
+ XConfigureWindow(dpy, f->win, CWSibling|CWStackMode, &wc);
+ wc.sibling = f->win;
+ }
+ XSync(dpy, True); // avoids flicker on monocle / deck layouts
+ }
} else {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
@@ -859,7 +893,8 @@ focusstack(const Arg *arg)
@@ -841,6 +876,7 @@ void
focusstack(const Arg *arg)
{
Client *c = NULL, *i;
+ XEvent xev;
if (!selmon->sel)
return;
@@ -859,8 +895,10 @@ focusstack(const Arg *arg)
}
if (c) {
focus(c);
@ -389,9 +412,19 @@ index 74bf95a..e84bba1 100644
+ if (!focusedontop)
+ restack(selmon);
}
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &xev));
}
@@ -1042,6 +1077,7 @@ manage(Window w, XWindowAttributes *wa)
Atom
@@ -1028,6 +1066,7 @@ manage(Window w, XWindowAttributes *wa)
Client *c, *t = NULL;
Window trans = None;
XWindowChanges wc;
+ XEvent xev;
c = ecalloc(1, sizeof(Client));
c->win = w;
@@ -1042,6 +1081,7 @@ manage(Window w, XWindowAttributes *wa)
if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
c->mon = t->mon;
c->tags = t->tags;
@ -399,7 +432,7 @@ index 74bf95a..e84bba1 100644
} else {
c->mon = selmon;
applyrules(c);
@@ -1061,6 +1097,8 @@ manage(Window w, XWindowAttributes *wa)
@@ -1061,6 +1101,8 @@ manage(Window w, XWindowAttributes *wa)
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
configure(c); /* propagates border_width, if size doesn't change */
@ -408,15 +441,17 @@ index 74bf95a..e84bba1 100644
if (getatomprop(c, netatom[NetWMState]) == netatom[NetWMFullscreen])
setfullscreen(c, 1);
updatesizehints(c);
@@ -1082,6 +1120,7 @@ manage(Window w, XWindowAttributes *wa)
@@ -1082,7 +1124,9 @@ manage(Window w, XWindowAttributes *wa)
c->mon->sel = c;
arrange(c->mon);
XMapWindow(dpy, c->win);
+
focus(NULL);
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &xev));
}
@@ -1565,6 +1604,7 @@ setup(void)
void
@@ -1565,6 +1609,7 @@ setup(void)
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);

Loading…
Cancel
Save