[wiki] [sites] [dwm][patches][noborderflicker] Add noborderflicker patch || Chris Down

From: <git_AT_suckless.org>
Date: Mon, 27 Dec 2021 14:46:07 +0100

commit bbba95cd3dac12e9a83a44e60fa546a3de0a3701
Author: Chris Down <chris_AT_chrisdown.name>
Date: Mon Dec 27 13:45:22 2021 +0000

    [dwm][patches][noborderflicker] Add noborderflicker patch

diff --git a/dwm.suckless.org/patches/noborderflicker/dwm-noborderflicker-20211227-8657affa2a61.diff b/dwm.suckless.org/patches/noborderflicker/dwm-noborderflicker-20211227-8657affa2a61.diff
new file mode 100644
index 00000000..9f3bb9b1
--- /dev/null
+++ b/dwm.suckless.org/patches/noborderflicker/dwm-noborderflicker-20211227-8657affa2a61.diff
_AT_@ -0,0 +1,41 @@
+diff --git dwm.c dwm.c
+index a96f33c..50ccf00 100644
+--- dwm.c
++++ dwm.c
+_AT_@ -236,6 +236,7 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
+ static void zoom(const Arg *arg);
+
+ /* variables */
++static Client *lastfocused = NULL;
+ static const char broken[] = "broken";
+ static char stext[256];
+ static int screen;
+_AT_@ -799,7 +800,10 @@ focus(Client *c)
+ detachstack(c);
+ attachstack(c);
+ grabbuttons(c, 1);
++ /* set new focused border first to avoid flickering */
+ XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
++ if (lastfocused)
++ XSetWindowBorder(dpy, lastfocused->win, scheme[SchemeNorm][ColBorder].pixel);
+ setfocus(c);
+ } else {
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+_AT_@ -1758,7 +1762,7 @@ unfocus(Client *c, int setfocus)
+ if (!c)
+ return;
+ grabbuttons(c, 0);
+- XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
++ lastfocused = c;
+ if (setfocus) {
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+ XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
+_AT_@ -1784,6 +1788,8 @@ unmanage(Client *c, int destroyed)
+ XSetErrorHandler(xerror);
+ XUngrabServer(dpy);
+ }
++ if (lastfocused == c)
++ lastfocused = NULL;
+ free(c);
+ focus(NULL);
+ updateclientlist();
diff --git a/dwm.suckless.org/patches/noborderflicker/index.md b/dwm.suckless.org/patches/noborderflicker/index.md
new file mode 100644
index 00000000..b6021383
--- /dev/null
+++ b/dwm.suckless.org/patches/noborderflicker/index.md
_AT_@ -0,0 +1,22 @@
+noborderflicker
+===============
+
+Description
+-----------
+Depending on machine configuration and luck, borders may flicker when changing
+focus to a new client. This happens because there may be a tangible delay
+between unfocus(), which sets the normal border, and focus(), which sets the
+focused border.
+
+This patch avoids that flickering by deferring drawing the normal border around
+the newly unfocused client until the new focused border has already been drawn.
+Even better, in reality, these are now close enough together that it's very
+likely the two updates will be rendered on the same monitor refresh.
+
+Download
+--------
+* [dwm-noborderflicker-20211227-8657affa2a61.diff](dwm-noborderflicker-20211227-8657affa2a61.diff)
+
+Authors
+-------
+* Chris Down - <chris_AT_chrisdown.name>
Received on Mon Dec 27 2021 - 14:46:07 CET

This archive was generated by hypermail 2.3.0 : Mon Dec 27 2021 - 14:48:44 CET