summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2019-09-14 00:36:18 +0200
committerbakkeby <[email protected]>2019-09-14 00:36:18 +0200
commit39e161e54519c8c28d479d69f5a1be88b59e3dac (patch)
tree7d04c12ff971c0eb66eb1b03b27132f861eadd72 /patch
parentc5b830e6ab1c570f19ff71badc5c4689c78f86f8 (diff)
downloaddwm-flexipatch-39e161e54519c8c28d479d69f5a1be88b59e3dac.tar.gz
dwm-flexipatch-39e161e54519c8c28d479d69f5a1be88b59e3dac.zip
Adding push patch
Diffstat (limited to 'patch')
-rw-r--r--patch/include.c4
-rw-r--r--patch/include.h4
-rw-r--r--patch/push.c71
-rw-r--r--patch/push.h4
4 files changed, 83 insertions, 0 deletions
diff --git a/patch/include.c b/patch/include.c
index 809a792..982fcfe 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -40,6 +40,10 @@
#include "pertag.c"
#endif
+#if PUSH_PATCH
+#include "push.c"
+#endif
+
#if ROTATESTACK_PATCH
#include "rotatestack.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index 9226f4d..ae948cd 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -36,6 +36,10 @@
#include "ewmhtags.h"
#endif
+#if PUSH_PATCH
+#include "push.h"
+#endif
+
#if ROTATESTACK_PATCH
#include "rotatestack.h"
#endif
diff --git a/patch/push.c b/patch/push.c
new file mode 100644
index 0000000..6ac156f
--- /dev/null
+++ b/patch/push.c
@@ -0,0 +1,71 @@
+Client *
+nextc(Client *c, float f)
+{
+ if (!f)
+ return nexttiled(c);
+
+ for (; c && !ISVISIBLE(c); c = c->next);
+ return c;
+}
+
+static Client *
+prevc(Client *c, float f)
+{
+ Client *p, *r;
+
+ for (p = selmon->clients, r = NULL; c && p && p != c; p = p->next)
+ if ((f || !p->isfloating) && ISVISIBLE(p))
+ r = p;
+ return r;
+}
+
+static void
+pushup(const Arg *arg)
+{
+ Client *sel = selmon->sel;
+ Client *c;
+
+ if (!sel || (sel->isfloating && !arg->f))
+ return;
+ if ((c = prevc(sel, arg->f))) {
+ /* attach before c */
+ detach(sel);
+ sel->next = c;
+ if (selmon->clients == c)
+ selmon->clients = sel;
+ else {
+ for (c = selmon->clients; c->next != sel->next; c = c->next);
+ c->next = sel;
+ }
+ } else {
+ /* move to the end */
+ for (c = sel; c->next; c = c->next);
+ detach(sel);
+ sel->next = NULL;
+ c->next = sel;
+ }
+ focus(sel);
+ arrange(selmon);
+}
+
+static void
+pushdown(const Arg *arg)
+{
+ Client *sel = selmon->sel;
+ Client *c;
+
+ if (!sel || (sel->isfloating && !arg->f))
+ return;
+ if ((c = nextc(sel->next, arg->f))) {
+ /* attach after c */
+ detach(sel);
+ sel->next = c->next;
+ c->next = sel;
+ } else {
+ /* move to the front */
+ detach(sel);
+ attach(sel);
+ }
+ focus(sel);
+ arrange(selmon);
+} \ No newline at end of file
diff --git a/patch/push.h b/patch/push.h
new file mode 100644
index 0000000..9cad8b3
--- /dev/null
+++ b/patch/push.h
@@ -0,0 +1,4 @@
+static Client * nextc(Client *c, float f);
+static Client * prevc(Client *c, float f);
+static void pushup(const Arg *arg);
+static void pushdown(const Arg *arg); \ No newline at end of file