diff options
author | Joe <bousset.rudy@gmail.com> | 2022-08-09 17:04:03 +0200 |
---|---|---|
committer | Joe <bousset.rudy@gmail.com> | 2022-08-09 17:04:03 +0200 |
commit | 3b22a84e02f43a42f7f54cf5c5764eddb929bd8b (patch) | |
tree | 97e7b377140f68320e92b5fc915c4efb1986d575 /dwm-6.3/movestack.c | |
parent | update to 6.3 in progress (diff) | |
download | dwm-3b22a84e02f43a42f7f54cf5c5764eddb929bd8b.tar.gz dwm-3b22a84e02f43a42f7f54cf5c5764eddb929bd8b.tar.bz2 dwm-3b22a84e02f43a42f7f54cf5c5764eddb929bd8b.tar.xz dwm-3b22a84e02f43a42f7f54cf5c5764eddb929bd8b.tar.zst dwm-3b22a84e02f43a42f7f54cf5c5764eddb929bd8b.zip |
update in progress
Diffstat (limited to 'dwm-6.3/movestack.c')
-rw-r--r-- | dwm-6.3/movestack.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/dwm-6.3/movestack.c b/dwm-6.3/movestack.c new file mode 100644 index 0000000..8d22a6b --- /dev/null +++ b/dwm-6.3/movestack.c @@ -0,0 +1,48 @@ +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); + } +} |