From f9104b06153ff2b5f6db50ba828b2dccaffe49cc Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 8 May 2019 07:10:53 +0100 Subject: [PATCH 1/2] Applies the movestack patch --- config.def.h | 3 +++ movestack.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 movestack.c diff --git a/config.def.h b/config.def.h index 1c0b587..ebeb3f4 100644 --- a/config.def.h +++ b/config.def.h @@ -59,6 +59,7 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "st", NULL }; +#include "movestack.c" static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_p, spawn, {.v = dmenucmd } }, @@ -66,6 +67,8 @@ static Key keys[] = { { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, + { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, diff --git a/movestack.c b/movestack.c new file mode 100644 index 0000000..c040462 --- /dev/null +++ b/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); + } +} + From 41c868c3b4a85f3ed62de2de9c528658a73b20b0 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 8 May 2019 07:13:42 +0100 Subject: [PATCH 2/2] Adds the shifting options to the man page --- dwm.1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dwm.1 b/dwm.1 index 13b3729..e001a25 100644 --- a/dwm.1 +++ b/dwm.1 @@ -98,6 +98,12 @@ Focus next window. .B Mod1\-k Focus previous window. .TP +.B Mod1\-Shift\-j +Moves the focused window down in the stack +.TP +.B Mod1\-Shift\-k +Moves the focused window up in the stack +.TP .B Mod1\-i Increase number of windows in master area. .TP