From 7d1a34e011c52f5a9b365ab0b5a59551948d0b6c Mon Sep 17 00:00:00 2001 From: irrlicht Date: Sun, 12 Apr 2026 21:07:21 +0200 Subject: [PATCH] Movestack wrap overflow --- dwl.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dwl.c b/dwl.c index 7eb317d..0dd664b 100644 --- a/dwl.c +++ b/dwl.c @@ -3109,17 +3109,22 @@ movestack(const Arg *arg) if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating) return; + int wrap = 0; if (arg->i > 0) { wl_list_for_each(c, &sel->link, link) { - if (&c->link == &clients) + if (&c->link == &clients) { + wrap = 1; continue; + } if (VISIBLEON(c, selmon) && !c->isfloating) break; } } else { wl_list_for_each_reverse(c, &sel->link, link) { - if (&c->link == &clients) + if (&c->link == &clients) { + wrap = 1; continue; + } if (VISIBLEON(c, selmon) && !c->isfloating) break; } @@ -3127,7 +3132,7 @@ movestack(const Arg *arg) if (c == sel) return; wl_list_remove(&sel->link); - if (arg->i > 0) + if ((arg->i > 0) ^ wrap) wl_list_insert(&c->link, &sel->link); else wl_list_insert(c->link.prev, &sel->link);