diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-23 15:12:58 +0530 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-23 15:38:10 +0530 |
commit | 0d4564c840a06dfc1c913e8a5d09b487d84619eb (patch) | |
tree | 4e0617733d66f83b5ae301438df8cb933e787352 /dwm.c | |
parent | 323ea47a968707bd65c2783afad6923bfeb44565 (diff) | |
download | dwm-0d4564c840a06dfc1c913e8a5d09b487d84619eb.tar.gz dwm-0d4564c840a06dfc1c913e8a5d09b487d84619eb.tar.bz2 dwm-0d4564c840a06dfc1c913e8a5d09b487d84619eb.zip |
Added patch dwm-inplacerotate
Diffstat (limited to 'dwm.c')
-rw-r--r-- | dwm.c | 59 |
1 files changed, 59 insertions, 0 deletions
@@ -184,6 +184,7 @@ static int gettextprop(Window w, Atom atom, char *text, unsigned int size); static void grabbuttons(Client *c, int focused); static void grabkeys(void); static void incnmaster(const Arg *arg); +static void inplacerotate(const Arg *arg); static void keypress(XEvent *e); static void killclient(const Arg *arg); static void manage(Window w, XWindowAttributes *wa); @@ -2382,6 +2383,64 @@ main(int argc, char *argv[]) } void +insertclient(Client *item, Client *insertItem, int after) { + Client *c; + if (item == NULL || insertItem == NULL || item == insertItem) return; + detach(insertItem); + if (!after && selmon->clients == item) { + attach(insertItem); + return; + } + if (after) { + c = item; + } else { + for (c = selmon->clients; c; c = c->next) { if (c->next == item) break; } + } + insertItem->next = c->next; + c->next = insertItem; +} + +void +inplacerotate(const Arg *arg) +{ + 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; + + // 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; } + stail = c; + i++; + } + } + + // All clients rotate + if (arg->i == 2) insertclient(selmon->clients, stail, 0); + if (arg->i == -2) insertclient(stail, selmon->clients, 1); + // Stack xor master rotate + if (arg->i == -1 && selidx >= selmon->nmaster) insertclient(stail, shead, 1); + if (arg->i == 1 && selidx >= selmon->nmaster) insertclient(shead, stail, 0); + if (arg->i == -1 && selidx < selmon->nmaster) insertclient(mtail, mhead, 1); + if (arg->i == 1 && selidx < selmon->nmaster) insertclient(mhead, mtail, 0); + + // 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; } + i++; + } + arrange(selmon); + focus(c); +} + +void centeredmaster(Monitor *m) { unsigned int i, n, h, mw, mx, my, oty, ety, tw; |