Adding inplacerotate patch
This commit is contained in:
@@ -32,6 +32,9 @@
|
||||
#if EWMHTAGS_PATCH
|
||||
#include "ewmhtags.c"
|
||||
#endif
|
||||
#if EXRESIZE_PATCH
|
||||
#include "exresize.c"
|
||||
#endif
|
||||
#if FAKEFULLSCREEN_CLIENT_PATCH
|
||||
#include "fakefullscreenclient.c"
|
||||
#endif
|
||||
@@ -47,8 +50,8 @@
|
||||
#if HOLDBAR_PATCH
|
||||
#include "holdbar.c"
|
||||
#endif
|
||||
#if EXRESIZE_PATCH
|
||||
#include "exresize.c"
|
||||
#if INPLACEROTATE_PATCH
|
||||
#include "inplacerotate.c"
|
||||
#endif
|
||||
#if KILLUNSEL_PATCH
|
||||
#include "killunsel.c"
|
||||
|
@@ -50,6 +50,9 @@
|
||||
#if HOLDBAR_PATCH
|
||||
#include "holdbar.h"
|
||||
#endif
|
||||
#if INPLACEROTATE_PATCH
|
||||
#include "inplacerotate.h"
|
||||
#endif
|
||||
#if KILLUNSEL_PATCH
|
||||
#include "killunsel.h"
|
||||
#endif
|
||||
|
53
patch/inplacerotate.c
Normal file
53
patch/inplacerotate.c
Normal file
@@ -0,0 +1,53 @@
|
||||
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;
|
||||
|
||||
// Shift client
|
||||
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++;
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
// 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);
|
||||
}
|
1
patch/inplacerotate.h
Normal file
1
patch/inplacerotate.h
Normal file
@@ -0,0 +1 @@
|
||||
static void inplacerotate(const Arg *arg);
|
Reference in New Issue
Block a user