diff options
author | Acid Bong <acid-bong@cock.lt> | 2022-10-19 13:04:58 +0300 |
---|---|---|
committer | Acid Bong <acid-bong@cock.lt> | 2022-10-19 13:04:58 +0300 |
commit | 55c72c9467270d2660af66e2052b876eec254104 (patch) | |
tree | 81476d983ffb7ab52729705f3d54bfb54dfa2f4b /patches/5-movestack-20211115-a786211.diff | |
parent | 47cdf02e01103d2d16f74b90bd65a30201c9d80d (diff) | |
download | dwm-55c72c9467270d2660af66e2052b876eec254104.tar.gz |
personal movestack patch
Diffstat (limited to 'patches/5-movestack-20211115-a786211.diff')
-rw-r--r-- | patches/5-movestack-20211115-a786211.diff | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/patches/5-movestack-20211115-a786211.diff b/patches/5-movestack-20211115-a786211.diff new file mode 100644 index 0000000..4428611 --- /dev/null +++ b/patches/5-movestack-20211115-a786211.diff @@ -0,0 +1,93 @@ +From 47cdf02e01103d2d16f74b90bd65a30201c9d80d Mon Sep 17 00:00:00 2001 +From: Acid Bong <acid-bong@cock.lt> +Date: Wed, 19 Oct 2022 13:03:12 +0300 +Subject: [PATCH] patch: movestack + +--- + config.def.h | 6 ++++++ + movestack.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 54 insertions(+) + create mode 100644 movestack.c + +diff --git a/config.def.h b/config.def.h +index c954087..b8f0908 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -58,6 +58,7 @@ static const char *dmenucmd[] = { "rofi", "-show", "drun", "-show-icons", NULL } + static const char *termcmd[] = { "st", NULL }; + + #include <X11/XF86keysym.h> ++#include "movestack.c" + static const Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_space, spawn, {.v = dmenucmd } }, +@@ -118,6 +119,11 @@ static const Key keys[] = { + { 0, XF86XK_AudioNext, spawn, SHCMD("playerctl next") }, + /* misc */ + { 0, XF86XK_TouchpadToggle, spawn, SHCMD("tp-toggle") }, ++ /* movestack patch */ ++ { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, /* vim keys */ ++ { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, ++ { MODKEY|ShiftMask, XK_Down, movestack, {.i = +1 } }, /* arrow keys */ ++ { MODKEY|ShiftMask, XK_Up, movestack, {.i = -1 } }, + }; + + /* button definitions */ +diff --git a/movestack.c b/movestack.c +new file mode 100644 +index 0000000..520f4ae +--- /dev/null ++++ b/movestack.c +@@ -0,0 +1,48 @@ ++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 +-- +2.38.0 + |