From 5c80a54b623a72b0855a9d46575565cc446f3bd6 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Tue, 18 Jan 2022 11:08:34 +0100 Subject: [PATCH] Refactoring restack to allow it to work without having the bar as a reference ref. #214 --- dwm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dwm.c b/dwm.c index 803f77a..03ea7c3 100644 --- a/dwm.c +++ b/dwm.c @@ -3000,7 +3000,7 @@ resizemouse(const Arg *arg) void restack(Monitor *m) { - Client *c; + Client *c, *f = NULL; XEvent ev; XWindowChanges wc; #if WARP_PATCH && FLEXTILE_DELUXE_LAYOUT @@ -3015,11 +3015,17 @@ restack(Monitor *m) return; if (m->sel->isfloating || !m->lt[m->sellt]->arrange) XRaiseWindow(dpy, m->sel->win); - if (m->lt[m->sellt]->arrange && m->bar) { + if (m->lt[m->sellt]->arrange) { wc.stack_mode = Below; - wc.sibling = m->bar->win; + if (m->bar) { + wc.sibling = m->bar->win; + } else { + for (f = m->stack; f && (f->isfloating || !ISVISIBLE(f)); f = f->snext); // find first tiled stack client + if (f) + wc.sibling = f->win; + } for (c = m->stack; c; c = c->snext) - if (!c->isfloating && ISVISIBLE(c)) { + if (!c->isfloating && ISVISIBLE(c) && c != f) { XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); wc.sibling = c->win; }