summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2020-01-17 09:54:23 +0100
committerbakkeby <[email protected]>2020-01-17 09:54:23 +0100
commit83a7b16a864bf36525c9dd3d53c1895de5de3864 (patch)
treeb4d69c60acc4c153079558cbb1d49d553dedefce /patch
parentbf4fdc6484513bdda749e537d8f28b775e771d48 (diff)
downloaddwm-flexipatch-83a7b16a864bf36525c9dd3d53c1895de5de3864.tar.gz
dwm-flexipatch-83a7b16a864bf36525c9dd3d53c1895de5de3864.zip
Adding inplacerotate patch
Diffstat (limited to 'patch')
-rw-r--r--patch/include.c7
-rw-r--r--patch/include.h3
-rw-r--r--patch/inplacerotate.c53
-rw-r--r--patch/inplacerotate.h1
4 files changed, 62 insertions, 2 deletions
diff --git a/patch/include.c b/patch/include.c
index 346839c..2e9cbf2 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -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"
diff --git a/patch/include.h b/patch/include.h
index bce929e..06f4f0a 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -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
diff --git a/patch/inplacerotate.c b/patch/inplacerotate.c
new file mode 100644
index 0000000..28eb289
--- /dev/null
+++ b/patch/inplacerotate.c
@@ -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);
+} \ No newline at end of file
diff --git a/patch/inplacerotate.h b/patch/inplacerotate.h
new file mode 100644
index 0000000..2767ad1
--- /dev/null
+++ b/patch/inplacerotate.h
@@ -0,0 +1 @@
+static void inplacerotate(const Arg *arg); \ No newline at end of file