Adding movestack patch

pull/32/head
bakkeby 5 years ago
parent 8c768b21e1
commit e0a21f0869

@ -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)

@ -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 } },

@ -56,6 +56,10 @@
#include "maximize.c"
#endif
#if MOVESTACK_PATCH
#include "movestack.c"
#endif
#if PERTAG_PATCH
#include "pertag.c"
#endif

@ -56,6 +56,10 @@
#include "maximize.h"
#endif
#if MOVESTACK_PATCH
#include "movestack.h"
#endif
#if PERTAG_PATCH
#include "pertag.h"
#endif

@ -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);
}
}

@ -0,0 +1 @@
static void movestack(const Arg *arg);

@ -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/

Loading…
Cancel
Save