summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2019-10-04 23:13:55 +0200
committerbakkeby <[email protected]>2019-10-04 23:13:55 +0200
commite0a21f0869904eb819e559a14f46820279b993cc (patch)
tree4ef165ddb76d569e9c87da1cc3291a9b26c0e390
parent8c768b21e1955e751d3992adcc3c76ef9f49d82e (diff)
downloaddwm-flexipatch-e0a21f0869904eb819e559a14f46820279b993cc.tar.gz
dwm-flexipatch-e0a21f0869904eb819e559a14f46820279b993cc.zip
Adding movestack patch
-rw-r--r--README.md5
-rw-r--r--config.def.h8
-rw-r--r--patch/include.c4
-rw-r--r--patch/include.h4
-rw-r--r--patch/movestack.c49
-rw-r--r--patch/movestack.h1
-rw-r--r--patches.h5
7 files changed, 73 insertions, 3 deletions
diff --git a/README.md b/README.md
index 97568c2..c336ef4 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
-2019-10-04 - Added maximize and monoclesymbol patches
+2019-10-04 - Added maximize, movestack and monoclesymbol patches
2019-10-03 - Added onlyquitonempty and switchcol patches
@@ -146,6 +146,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- always display the the monocle-symbol as defined in config.h if the monocle-layout is activated
- do not display the number of open clients in the current tag
+ - [movestack](https://dwm.suckless.org/patches/movestack/)
+ - allows you to move clients around in the stack and swap them with the master
+
- [onlyquitonempty](https://dwm.suckless.org/patches/onlyquitonempty/)
- makes it so dwm will only exit via quit() if no windows are open (in order to prevent accidental loss of work)
diff --git a/config.def.h b/config.def.h
index 1cda331..388cdea 100644
--- a/config.def.h
+++ b/config.def.h
@@ -320,8 +320,8 @@ static Key keys[] = {
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
#if ROTATESTACK_PATCH
- { MODKEY|ShiftMask, XK_j, rotatestack, {.i = +1 } },
- { MODKEY|ShiftMask, XK_k, rotatestack, {.i = -1 } },
+ { MODKEY|Mod4Mask, XK_j, rotatestack, {.i = +1 } },
+ { MODKEY|Mod4Mask, XK_k, rotatestack, {.i = -1 } },
#endif // ROTATESTACK_PATCH
#if PUSH_PATCH || PUSH_NO_MASTER_PATCH
{ MODKEY|ControlMask, XK_j, pushdown, {0} },
@@ -336,6 +336,10 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_l, setcfact, {.f = -0.25} },
{ MODKEY|ShiftMask, XK_o, setcfact, {.f = 0.00} },
#endif // CFACTS_PATCH
+ #if MOVESTACK_PATCH
+ { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
+ #endif // MOVESTACK_PATCH
{ MODKEY, XK_Return, zoom, {0} },
#if VANITYGAPS_PATCH
{ MODKEY|Mod4Mask, XK_u, incrgaps, {.i = +1 } },
diff --git a/patch/include.c b/patch/include.c
index 3db5a6d..fa6905c 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -56,6 +56,10 @@
#include "maximize.c"
#endif
+#if MOVESTACK_PATCH
+#include "movestack.c"
+#endif
+
#if PERTAG_PATCH
#include "pertag.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index afdbf87..f78287d 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -56,6 +56,10 @@
#include "maximize.h"
#endif
+#if MOVESTACK_PATCH
+#include "movestack.h"
+#endif
+
#if PERTAG_PATCH
#include "pertag.h"
#endif
diff --git a/patch/movestack.c b/patch/movestack.c
new file mode 100644
index 0000000..2406a87
--- /dev/null
+++ b/patch/movestack.c
@@ -0,0 +1,49 @@
+void
+movestack(const Arg *arg)
+{
+ Client *c = NULL, *p = NULL, *pc = NULL, *i;
+
+ if (arg->i > 0) {
+ /* find the client after selmon->sel */
+ for (c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
+ if (!c)
+ for (c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
+
+ }
+ else {
+ /* find the client before selmon->sel */
+ for (i = selmon->clients; i != selmon->sel; i = i->next)
+ if(ISVISIBLE(i) && !i->isfloating)
+ c = i;
+ if (!c)
+ for (; i; i = i->next)
+ if (ISVISIBLE(i) && !i->isfloating)
+ c = i;
+ }
+ /* find the client before selmon->sel and c */
+ for (i = selmon->clients; i && (!p || !pc); i = i->next) {
+ if (i->next == selmon->sel)
+ p = i;
+ if (i->next == c)
+ pc = i;
+ }
+
+ /* swap c and selmon->sel selmon->clients in the selmon->clients list */
+ if (c && c != selmon->sel) {
+ Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
+ selmon->sel->next = c->next==selmon->sel?c:c->next;
+ c->next = temp;
+
+ if (p && p != c)
+ p->next = c;
+ if (pc && pc != selmon->sel)
+ pc->next = selmon->sel;
+
+ if (selmon->sel == selmon->clients)
+ selmon->clients = c;
+ else if (c == selmon->clients)
+ selmon->clients = selmon->sel;
+
+ arrange(selmon);
+ }
+} \ No newline at end of file
diff --git a/patch/movestack.h b/patch/movestack.h
new file mode 100644
index 0000000..19ac5d8
--- /dev/null
+++ b/patch/movestack.h
@@ -0,0 +1 @@
+static void movestack(const Arg *arg); \ No newline at end of file
diff --git a/patches.h b/patches.h
index ff31936..026e38d 100644
--- a/patches.h
+++ b/patches.h
@@ -209,6 +209,11 @@
*/
#define MONOCLESYMBOL_PATCH 0
+/* This patch allows you to move clients around in the stack and swap them with the master.
+ * https://dwm.suckless.org/patches/movestack/
+ */
+#define MOVESTACK_PATCH 0
+
/* This patch makes it so dwm will only exit via quit() if no windows are open.
* This is to prevent you accidentally losing all your work.
* https://dwm.suckless.org/patches/onlyquitonempty/