From 5f76b12596d30e0721c7ed2d138d216350c58029 Mon Sep 17 00:00:00 2001 From: speedie Date: Wed, 30 Nov 2022 17:49:05 +0100 Subject: [PATCH] prevent border flicker --- speedwm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/speedwm.c b/speedwm.c index f7f16b3..4de844a 100644 --- a/speedwm.c +++ b/speedwm.c @@ -779,6 +779,7 @@ static const char notitle[] = ""; /* Title when none can be grabbed. */ #if USEMOUSE static const char *layoutcmd = "speedwm-utils layout"; #endif +static Client *lastfocused = NULL; static char stext[1024]; /* max character count */ static char rawstext[1024]; /* max character count */ static int statusw; @@ -2862,6 +2863,10 @@ focus(Client *c) /* draw window border for the focused window */ XSetWindowBorder(dpy, c->win, scheme[SchemeBorderSel][ColBorder].pixel); + /* lastfocused may be us if another window was unmanaged */ + if (lastfocused && lastfocused != c) + XSetWindowBorder(dpy, lastfocused->win, scheme[SchemeBorderNorm][ColBorder].pixel); + /* set focus */ setfocus(c); @@ -6379,7 +6384,7 @@ unfocus(Client *c, int setfocus) #if USEFADE opacity(c, inactiveopacity); #endif - XSetWindowBorder(dpy, c->win, scheme[SchemeBorderNorm][ColBorder].pixel); + lastfocused = c; if (setfocus) { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XDeleteProperty(dpy, root, netatom[NetActiveWindow]); @@ -6426,6 +6431,10 @@ unmanage(Client *c, int destroyed) } if (scratchpad_last_showed == c) scratchpad_last_showed = NULL; + + if (lastfocused == c) + lastfocused = NULL; + free(c); if (!s) {