diff options
| author | bakkeby <[email protected]> | 2021-04-06 11:25:45 +0200 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2021-04-06 11:25:45 +0200 |
| commit | 905dc4d7afda05ca5dcc7c2f6dc9f0b25c7f8cda (patch) | |
| tree | 77cfb954c16773be69fce48940a6872614c95ab4 /patch/inplacerotate.c | |
| parent | 39df1ca4ada8374da4b0c3f29ee8d284f1a95752 (diff) | |
| download | dwm-flexipatch-905dc4d7afda05ca5dcc7c2f6dc9f0b25c7f8cda.tar.gz dwm-flexipatch-905dc4d7afda05ca5dcc7c2f6dc9f0b25c7f8cda.zip | |
Updating inplacerotate to include rotatestack feature ref. #108
Diffstat (limited to 'patch/inplacerotate.c')
| -rw-r--r-- | patch/inplacerotate.c | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/patch/inplacerotate.c b/patch/inplacerotate.c index 28eb289..fe6befb 100644 --- a/patch/inplacerotate.c +++ b/patch/inplacerotate.c @@ -2,7 +2,8 @@ void insertclient(Client *item, Client *insertItem, int after) { Client *c; - if (item == NULL || insertItem == NULL || item == insertItem) return; + if (item == NULL || insertItem == NULL || item == insertItem) + return; detach(insertItem); if (!after && selmon->clients == item) { attach(insertItem); @@ -11,7 +12,10 @@ insertclient(Client *item, Client *insertItem, int after) if (after) { c = item; } else { - for (c = selmon->clients; c; c = c->next) { if (c->next == item) break; } + for (c = selmon->clients; c; c = c->next) { + if (c->next == item) + break; + } } insertItem->next = c->next; c->next = insertItem; @@ -20,32 +24,58 @@ insertclient(Client *item, Client *insertItem, int after) void inplacerotate(const Arg *arg) { - if (!selmon->sel || (selmon->sel->isfloating && !arg->f)) return; + if (!selmon->sel || (selmon->sel->isfloating && !arg->f)) + return; unsigned int selidx = 0, i = 0; Client *c = NULL, *stail = NULL, *mhead = NULL, *mtail = NULL, *shead = NULL; - // Shift client + // Determine positionings for insertclient for (c = selmon->clients; c; c = c->next) { if (ISVISIBLE(c) && !(c->isfloating)) { - if (selmon->sel == c) { selidx = i; } - if (i == selmon->nmaster - 1) { mtail = c; } - if (i == selmon->nmaster) { shead = c; } - if (mhead == NULL) { mhead = c; } + if (selmon->sel == c) + selidx = i; + if (i == selmon->nmaster - 1) + mtail = c; + if (i == selmon->nmaster) + shead = c; + if (mhead == NULL) + mhead = c; stail = c; i++; } } - if (arg->i < 0 && selidx >= selmon->nmaster) insertclient(stail, shead, 1); - if (arg->i > 0 && selidx >= selmon->nmaster) insertclient(shead, stail, 0); - if (arg->i < 0 && selidx < selmon->nmaster) insertclient(mtail, mhead, 1); - if (arg->i > 0 && selidx < selmon->nmaster) insertclient(mhead, mtail, 0); + + switch(arg->i) { + case 1: + if (selidx >= selmon->nmaster) + insertclient(shead, stail, 0); + else + insertclient(mhead, mtail, 0); + break; + case -1: + if (selidx >= selmon->nmaster) + insertclient(stail, shead, 1); + else + insertclient(mtail, mhead, 1); + break; + case 2: + insertclient(selmon->clients, stail, 0); + break; + case -2: + insertclient(stail, selmon->clients, 1); + break; + } // Restore focus position i = 0; for (c = selmon->clients; c; c = c->next) { - if (!ISVISIBLE(c) || (c->isfloating)) continue; - if (i == selidx) { focus(c); break; } + if (!ISVISIBLE(c) || (c->isfloating)) + continue; + if (i == selidx) { + focus(c); + break; + } i++; } arrange(selmon); |
