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 @@ -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: @@ -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); @@ -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