dwm

Suckless' dwm with my personal patches
git clone https://git.instinctive.eu/dwm.git
Log | Files | Refs | README | LICENSE

commit 29b31b5c95273e541c93fad7eb4cd64548580d68
parent 8c0cf76a6fa37d29d74e7ddf1f09c688d470d650
Author: Natasha Kerensikova <natacha@instinctive.eu>
Date:   Sun,  9 Jun 2024 17:14:11 +0200

[nat] Preserve client order from removed monitors

Diffstat:
Mdwm.c | 16++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/dwm.c b/dwm.c @@ -2561,6 +2561,7 @@ updategeom(void) if (XineramaIsActive(dpy)) { int i, j, n, nn; Client *c; + Client **tc; Monitor *m; XineramaScreenInfo *info = XineramaQueryScreens(dpy, &nn); XineramaScreenInfo *unique = NULL; @@ -2598,13 +2599,16 @@ updategeom(void) /* removed monitors if n > nn */ for (i = nn; i < n; i++) { for (m = mons; m && m->next; m = m->next); - while ((c = m->clients)) { + if (m->clients) { dirty = 1; - m->clients = c->next; - detachstack(c); - c->mon = mons; - attach(c); - attachstack(c); + for (c = m->clients; c; c = c->next) + c->mon = mons; + for (tc = &mons->clients; *tc; tc = &(*tc)->next); + *tc = m->clients; + m->clients = NULL; + for (tc = &mons->stack; *tc; tc = &(*tc)->snext); + *tc = m->stack; + m->stack = NULL; } if (m == selmon) selmon = mons;