[hackers] [tabbed][PATCH] Fix clients blinking on tabbar cleanup

From: Nikita Zlobin <nick87720z_AT_gmail.com>
Date: Thu, 11 Jun 2020 15:59:37 +0500

If tabbar had many windows, when closed itself, reparented clients may
occasionally appear on their own for moment before to disappear.
Unmapping before reparent seems to fix this.

And killclient() by index if possible to avoid tinker with focus.
---
 tabbed.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/tabbed.c b/tabbed.c
index d426c0d..698ffcb 100644
--- a/tabbed.c
+++ b/tabbed.c
_AT_@ -195,8 +195,8 @@ buttonpress(const XEvent *e)
 				focus(i);
 				break;
 			case Button2:
-				focus(i);
-				killclient(NULL);
+				arg.i = i;
+				killclient(&arg);
 				break;
 			case Button4: /* FALLTHROUGH */
 			case Button5:
_AT_@ -213,10 +213,12 @@ void
 cleanup(void)
 {
 	int i;
+	Arg arg;
 
 	for (i = 0; i < nclients; i++) {
-		focus(i);
-		killclient(NULL);
+		arg.i = i;
+		killclient(&arg);
+		XUnmapWindow(dpy, clients[i]->win);
 		XReparentWindow(dpy, clients[i]->win, root, 0, 0);
 	}
 	free(clients);
_AT_@ -677,21 +679,26 @@ void
 killclient(const Arg *arg)
 {
 	XEvent ev;
+	int i;
 
-	if (sel < 0)
+	if (arg)
+		i = arg->i;
+	else if (sel >= 0)
+		i = sel;
+	else
 		return;
 
-	if (isprotodel(sel) && !clients[sel]->closed) {
+	if (isprotodel(i) && !clients[i]->closed) {
 		ev.type = ClientMessage;
-		ev.xclient.window = clients[sel]->win;
+		ev.xclient.window = clients[i]->win;
 		ev.xclient.message_type = wmatom[WMProtocols];
 		ev.xclient.format = 32;
 		ev.xclient.data.l[0] = wmatom[WMDelete];
 		ev.xclient.data.l[1] = CurrentTime;
-		XSendEvent(dpy, clients[sel]->win, False, NoEventMask, &ev);
-		clients[sel]->closed = True;
+		XSendEvent(dpy, clients[i]->win, False, NoEventMask, &ev);
+		clients[i]->closed = True;
 	} else {
-		XKillClient(dpy, clients[sel]->win);
+		XKillClient(dpy, clients[i]->win);
 	}
 }
 
-- 
2.26.2
Received on Thu Jun 11 2020 - 12:59:37 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 11 2020 - 13:00:52 CEST