dwm-noborderselflickerfix-2022042627-d93ff48803f0.diff (1604B)
1 diff --git dwm.c dwm.c 2 index 0fc328a..4a767bd 100644 3 --- dwm.c 4 +++ dwm.c 5 @@ -206,6 +206,7 @@ static void setup(void); 6 static void seturgent(Client *c, int urg); 7 static void showhide(Client *c); 8 static void sigchld(int unused); 9 +static int solitary(Client *c); 10 static void spawn(const Arg *arg); 11 static void tag(const Arg *arg); 12 static void tagmon(const Arg *arg); 13 @@ -802,7 +803,11 @@ focus(Client *c) 14 detachstack(c); 15 attachstack(c); 16 grabbuttons(c, 1); 17 - XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); 18 + /* Avoid flickering when another client appears and the border 19 + * is restored */ 20 + if (!solitary(c)) { 21 + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); 22 + } 23 setfocus(c); 24 } else { 25 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 26 @@ -1288,6 +1293,11 @@ resizeclient(Client *c, int x, int y, int w, int h) 27 c->oldw = c->w; c->w = wc.width = w; 28 c->oldh = c->h; c->h = wc.height = h; 29 wc.border_width = c->bw; 30 + if (solitary(c)) { 31 + c->w = wc.width += c->bw * 2; 32 + c->h = wc.height += c->bw * 2; 33 + wc.border_width = 0; 34 + } 35 XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); 36 configure(c); 37 XSync(dpy, False); 38 @@ -1642,6 +1652,15 @@ sigchld(int unused) 39 while (0 < waitpid(-1, NULL, WNOHANG)); 40 } 41 42 +int 43 +solitary(Client *c) 44 +{ 45 + return ((nexttiled(c->mon->clients) == c && !nexttiled(c->next)) 46 + || &monocle == c->mon->lt[c->mon->sellt]->arrange) 47 + && !c->isfullscreen && !c->isfloating 48 + && NULL != c->mon->lt[c->mon->sellt]->arrange; 49 +} 50 + 51 void 52 spawn(const Arg *arg) 53 {