summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2020-03-23 12:15:50 +0100
committerbakkeby <[email protected]>2020-03-23 12:15:50 +0100
commit7bc3cf765e4108f2020b68ecbe212d077156bc88 (patch)
treea51bcf5a912ae31a8b0732f3da6bfff85c8352f6 /patch
parentcd818c14bbee1e6f560414cb8eac70c8f24e8be5 (diff)
downloaddwm-flexipatch-7bc3cf765e4108f2020b68ecbe212d077156bc88.tar.gz
dwm-flexipatch-7bc3cf765e4108f2020b68ecbe212d077156bc88.zip
Adding stacker patch as requested ref. #17
Diffstat (limited to 'patch')
-rw-r--r--patch/include.c3
-rw-r--r--patch/include.h3
-rw-r--r--patch/stacker.c74
-rw-r--r--patch/stacker.h10
4 files changed, 90 insertions, 0 deletions
diff --git a/patch/include.c b/patch/include.c
index d7c3178..723147b 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -101,6 +101,9 @@
#include "sortscreens.c"
#endif // XINERAMA
#endif
+#if STACKER_PATCH
+#include "stacker.c"
+#endif
#if STICKY_PATCH
#include "sticky.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index aa77397..d97b503 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -101,6 +101,9 @@
#include "sortscreens.h"
#endif // XINERAMA
#endif
+#if STACKER_PATCH
+#include "stacker.h"
+#endif
#if STICKY_PATCH
#include "sticky.h"
#endif
diff --git a/patch/stacker.c b/patch/stacker.c
new file mode 100644
index 0000000..db6da82
--- /dev/null
+++ b/patch/stacker.c
@@ -0,0 +1,74 @@
+void
+focusstack(const Arg *arg)
+{
+ int i = stackpos(arg);
+ Client *c, *p;
+
+ if (i < 0)
+ return;
+
+ #if ALWAYSFULLSCREEN_PATCH
+ if (!selmon->sel || selmon->sel->isfullscreen)
+ return;
+ #endif // ALWAYSFULLSCREEN_PATCH
+
+ for (p = NULL, c = selmon->clients; c && (i || !ISVISIBLE(c));
+ i -= ISVISIBLE(c) ? 1 : 0, p = c, c = c->next);
+ focus(c ? c : p);
+ restack(selmon);
+}
+
+void
+pushstack(const Arg *arg)
+{
+ int i = stackpos(arg);
+ Client *sel = selmon->sel, *c, *p;
+
+ if (i < 0)
+ return;
+ else if (i == 0) {
+ detach(sel);
+ attach(sel);
+ }
+ else {
+ for (p = NULL, c = selmon->clients; c; p = c, c = c->next)
+ if (!(i -= (ISVISIBLE(c) && c != sel)))
+ break;
+ c = c ? c : p;
+ detach(sel);
+ sel->next = c->next;
+ c->next = sel;
+ }
+ arrange(selmon);
+}
+
+int
+stackpos(const Arg *arg)
+{
+ int n, i;
+ Client *c, *l;
+
+ if (!selmon->clients)
+ return -1;
+
+ if (arg->i == PREVSEL) {
+ for (l = selmon->stack; l && (!ISVISIBLE(l) || l == selmon->sel); l = l->snext);
+ if (!l)
+ return -1;
+ for (i = 0, c = selmon->clients; c != l; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
+ return i;
+ }
+ else if (ISINC(arg->i)) {
+ if(!selmon->sel)
+ return -1;
+ for (i = 0, c = selmon->clients; c != selmon->sel; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
+ for (n = i; c; n += ISVISIBLE(c) ? 1 : 0, c = c->next);
+ return MOD(i + GETINC(arg->i), n);
+ }
+ else if (arg->i < 0) {
+ for(i = 0, c = selmon->clients; c; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
+ return MAX(i + arg->i, 0);
+ }
+ else
+ return arg->i;
+} \ No newline at end of file
diff --git a/patch/stacker.h b/patch/stacker.h
new file mode 100644
index 0000000..0a06461
--- /dev/null
+++ b/patch/stacker.h
@@ -0,0 +1,10 @@
+#define GETINC(X) ((X) - 2000)
+#define INC(X) ((X) + 2000)
+#define ISINC(X) ((X) > 1000 && (X) < 3000)
+#define PREVSEL 3000
+#define MOD(N,M) ((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))
+#define TRUNC(X,A,B) (MAX((A), MIN((X), (B))))
+
+static void focusstack(const Arg *arg);
+static void pushstack(const Arg *arg);
+static int stackpos(const Arg *arg); \ No newline at end of file