feat(patches): add noborderselflickerfix

This commit is contained in:
augety 2024-08-25 14:17:32 +08:00
parent a5308d03a5
commit c9deb439fe
2 changed files with 73 additions and 1 deletions

19
dwm.c
View File

@ -220,6 +220,7 @@ static void show(const Arg *arg);
static void showall(const Arg *arg); static void showall(const Arg *arg);
static void showwin(Client *c); static void showwin(Client *c);
static void showhide(Client *c); static void showhide(Client *c);
static int solitary(Client *c);
static void spawn(const Arg *arg); static void spawn(const Arg *arg);
static void tag(const Arg *arg); static void tag(const Arg *arg);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
@ -873,7 +874,11 @@ focus(Client *c)
detachstack(c); detachstack(c);
attachstack(c); attachstack(c);
grabbuttons(c, 1); grabbuttons(c, 1);
/* Avoid flickering when another client appears and the border
* is restored */
if (!solitary(c)) {
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
}
setfocus(c); setfocus(c);
} else { } else {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@ -1488,6 +1493,11 @@ resizeclient(Client *c, int x, int y, int w, int h)
c->oldw = c->w; c->w = wc.width = w; c->oldw = c->w; c->w = wc.width = w;
c->oldh = c->h; c->h = wc.height = h; c->oldh = c->h; c->h = wc.height = h;
wc.border_width = c->bw; wc.border_width = c->bw;
if (solitary(c)) {
c->w = wc.width += c->bw * 2;
c->h = wc.height += c->bw * 2;
wc.border_width = 0;
}
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c); configure(c);
XSync(dpy, False); XSync(dpy, False);
@ -1966,6 +1976,15 @@ showhide(Client *c)
} }
} }
int
solitary(Client *c)
{
return ((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
|| &monocle == c->mon->lt[c->mon->sellt]->arrange)
&& !c->isfullscreen && !c->isfloating
&& NULL != c->mon->lt[c->mon->sellt]->arrange;
}
void void
spawn(const Arg *arg) spawn(const Arg *arg)
{ {

View File

@ -0,0 +1,53 @@
diff --git dwm.c dwm.c
index 0fc328a..4a767bd 100644
--- dwm.c
+++ dwm.c
@@ -206,6 +206,7 @@ static void setup(void);
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
static void sigchld(int unused);
+static int solitary(Client *c);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
@@ -802,7 +803,11 @@ focus(Client *c)
detachstack(c);
attachstack(c);
grabbuttons(c, 1);
- XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
+ /* Avoid flickering when another client appears and the border
+ * is restored */
+ if (!solitary(c)) {
+ XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
+ }
setfocus(c);
} else {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@@ -1288,6 +1293,11 @@ resizeclient(Client *c, int x, int y, int w, int h)
c->oldw = c->w; c->w = wc.width = w;
c->oldh = c->h; c->h = wc.height = h;
wc.border_width = c->bw;
+ if (solitary(c)) {
+ c->w = wc.width += c->bw * 2;
+ c->h = wc.height += c->bw * 2;
+ wc.border_width = 0;
+ }
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
XSync(dpy, False);
@@ -1642,6 +1652,15 @@ sigchld(int unused)
while (0 < waitpid(-1, NULL, WNOHANG));
}
+int
+solitary(Client *c)
+{
+ return ((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
+ || &monocle == c->mon->lt[c->mon->sellt]->arrange)
+ && !c->isfullscreen && !c->isfloating
+ && NULL != c->mon->lt[c->mon->sellt]->arrange;
+}
+
void
spawn(const Arg *arg)
{