summaryrefslogtreecommitdiff
path: root/tree/src/dwm/dwm-6.6/movestack.c
diff options
context:
space:
mode:
authorThomas Ulmer <thomasmulmer02@gmail.com>2026-02-04 14:33:05 -0800
committerThomas Ulmer <thomasmulmer02@gmail.com>2026-02-04 14:33:05 -0800
commitbe7fb7b57a97147b40b5d8203f6241015755a51d (patch)
tree79bb694f714d5861c3dd6f6cc548986fce5f1429 /tree/src/dwm/dwm-6.6/movestack.c
parentb378cb8f0e774b3e21671fca22de20b71cbac214 (diff)
suckless includes
Diffstat (limited to 'tree/src/dwm/dwm-6.6/movestack.c')
-rw-r--r--tree/src/dwm/dwm-6.6/movestack.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/tree/src/dwm/dwm-6.6/movestack.c b/tree/src/dwm/dwm-6.6/movestack.c
new file mode 100644
index 0000000..c040462
--- /dev/null
+++ b/tree/src/dwm/dwm-6.6/movestack.c
@@ -0,0 +1,49 @@
+void
+movestack(const Arg *arg) {
+ Client *c = NULL, *p = NULL, *pc = NULL, *i;
+
+ if(arg->i > 0) {
+ /* find the client after selmon->sel */
+ for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
+ if(!c)
+ for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
+
+ }
+ else {
+ /* find the client before selmon->sel */
+ for(i = selmon->clients; i != selmon->sel; i = i->next)
+ if(ISVISIBLE(i) && !i->isfloating)
+ c = i;
+ if(!c)
+ for(; i; i = i->next)
+ if(ISVISIBLE(i) && !i->isfloating)
+ c = i;
+ }
+ /* find the client before selmon->sel and c */
+ for(i = selmon->clients; i && (!p || !pc); i = i->next) {
+ if(i->next == selmon->sel)
+ p = i;
+ if(i->next == c)
+ pc = i;
+ }
+
+ /* swap c and selmon->sel selmon->clients in the selmon->clients list */
+ if(c && c != selmon->sel) {
+ Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
+ selmon->sel->next = c->next==selmon->sel?c:c->next;
+ c->next = temp;
+
+ if(p && p != c)
+ p->next = c;
+ if(pc && pc != selmon->sel)
+ pc->next = selmon->sel;
+
+ if(selmon->sel == selmon->clients)
+ selmon->clients = c;
+ else if(c == selmon->clients)
+ selmon->clients = selmon->sel;
+
+ arrange(selmon);
+ }
+}
+