mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Updating inplacerotate to include rotatestack feature ref. #108
This commit is contained in:
parent
39df1ca4ad
commit
905dc4d7af
@ -820,6 +820,8 @@ static Key keys[] = {
|
|||||||
{ MODKEY|Mod4Mask, XK_k, rotatestack, {.i = -1 } },
|
{ MODKEY|Mod4Mask, XK_k, rotatestack, {.i = -1 } },
|
||||||
#endif // ROTATESTACK_PATCH
|
#endif // ROTATESTACK_PATCH
|
||||||
#if INPLACEROTATE_PATCH
|
#if INPLACEROTATE_PATCH
|
||||||
|
{ MODKEY|Mod4Mask, XK_j, inplacerotate, {.i = +2 } }, // same as rotatestack
|
||||||
|
{ MODKEY|Mod4Mask, XK_k, inplacerotate, {.i = -2 } }, // same as reotatestack
|
||||||
{ MODKEY|Mod4Mask|ShiftMask, XK_j, inplacerotate, {.i = +1} },
|
{ MODKEY|Mod4Mask|ShiftMask, XK_j, inplacerotate, {.i = +1} },
|
||||||
{ MODKEY|Mod4Mask|ShiftMask, XK_k, inplacerotate, {.i = -1} },
|
{ MODKEY|Mod4Mask|ShiftMask, XK_k, inplacerotate, {.i = -1} },
|
||||||
#endif // INPLACEROTATE_PATCH
|
#endif // INPLACEROTATE_PATCH
|
||||||
|
@ -2,7 +2,8 @@ void
|
|||||||
insertclient(Client *item, Client *insertItem, int after)
|
insertclient(Client *item, Client *insertItem, int after)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
if (item == NULL || insertItem == NULL || item == insertItem) return;
|
if (item == NULL || insertItem == NULL || item == insertItem)
|
||||||
|
return;
|
||||||
detach(insertItem);
|
detach(insertItem);
|
||||||
if (!after && selmon->clients == item) {
|
if (!after && selmon->clients == item) {
|
||||||
attach(insertItem);
|
attach(insertItem);
|
||||||
@ -11,7 +12,10 @@ insertclient(Client *item, Client *insertItem, int after)
|
|||||||
if (after) {
|
if (after) {
|
||||||
c = item;
|
c = item;
|
||||||
} else {
|
} 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;
|
insertItem->next = c->next;
|
||||||
c->next = insertItem;
|
c->next = insertItem;
|
||||||
@ -20,32 +24,58 @@ insertclient(Client *item, Client *insertItem, int after)
|
|||||||
void
|
void
|
||||||
inplacerotate(const Arg *arg)
|
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;
|
unsigned int selidx = 0, i = 0;
|
||||||
Client *c = NULL, *stail = NULL, *mhead = NULL, *mtail = NULL, *shead = NULL;
|
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) {
|
for (c = selmon->clients; c; c = c->next) {
|
||||||
if (ISVISIBLE(c) && !(c->isfloating)) {
|
if (ISVISIBLE(c) && !(c->isfloating)) {
|
||||||
if (selmon->sel == c) { selidx = i; }
|
if (selmon->sel == c)
|
||||||
if (i == selmon->nmaster - 1) { mtail = c; }
|
selidx = i;
|
||||||
if (i == selmon->nmaster) { shead = c; }
|
if (i == selmon->nmaster - 1)
|
||||||
if (mhead == NULL) { mhead = c; }
|
mtail = c;
|
||||||
|
if (i == selmon->nmaster)
|
||||||
|
shead = c;
|
||||||
|
if (mhead == NULL)
|
||||||
|
mhead = c;
|
||||||
stail = c;
|
stail = c;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (arg->i < 0 && selidx >= selmon->nmaster) insertclient(stail, shead, 1);
|
|
||||||
if (arg->i > 0 && selidx >= selmon->nmaster) insertclient(shead, stail, 0);
|
switch(arg->i) {
|
||||||
if (arg->i < 0 && selidx < selmon->nmaster) insertclient(mtail, mhead, 1);
|
case 1:
|
||||||
if (arg->i > 0 && selidx < selmon->nmaster) insertclient(mhead, mtail, 0);
|
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
|
// Restore focus position
|
||||||
i = 0;
|
i = 0;
|
||||||
for (c = selmon->clients; c; c = c->next) {
|
for (c = selmon->clients; c; c = c->next) {
|
||||||
if (!ISVISIBLE(c) || (c->isfloating)) continue;
|
if (!ISVISIBLE(c) || (c->isfloating))
|
||||||
if (i == selidx) { focus(c); break; }
|
continue;
|
||||||
|
if (i == selidx) {
|
||||||
|
focus(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
|
Loading…
Reference in New Issue
Block a user