dwm-noborderflicker-20211227-8657affa2a61.diff (1358B)
1 diff --git dwm.c dwm.c 2 index a96f33c..34d1321 100644 3 --- dwm.c 4 +++ dwm.c 5 @@ -236,6 +236,7 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee); 6 static void zoom(const Arg *arg); 7 8 /* variables */ 9 +static Client *lastfocused = NULL; 10 static const char broken[] = "broken"; 11 static char stext[256]; 12 static int screen; 13 @@ -799,7 +800,11 @@ focus(Client *c) 14 detachstack(c); 15 attachstack(c); 16 grabbuttons(c, 1); 17 + /* set new focused border first to avoid flickering */ 18 XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); 19 + /* lastfocused may be us if another window was unmanaged */ 20 + if (lastfocused && lastfocused != c) 21 + XSetWindowBorder(dpy, lastfocused->win, scheme[SchemeNorm][ColBorder].pixel); 22 setfocus(c); 23 } else { 24 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 25 @@ -1758,7 +1763,7 @@ unfocus(Client *c, int setfocus) 26 if (!c) 27 return; 28 grabbuttons(c, 0); 29 - XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); 30 + lastfocused = c; 31 if (setfocus) { 32 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 33 XDeleteProperty(dpy, root, netatom[NetActiveWindow]); 34 @@ -1784,6 +1789,8 @@ unmanage(Client *c, int destroyed) 35 XSetErrorHandler(xerror); 36 XUngrabServer(dpy); 37 } 38 + if (lastfocused == c) 39 + lastfocused = NULL; 40 free(c); 41 focus(NULL); 42 updateclientlist();