From 6de03c1735b272a8081ffc8a25e078ec7e37f2c1 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 2 Feb 2020 11:55:19 +0100 Subject: [PATCH] Adding transferall patch --- README.md | 5 ++++- config.def.h | 3 +++ patch/include.c | 3 +++ patch/include.h | 3 +++ patch/transferall.c | 25 +++++++++++++++++++++++++ patch/transferall.h | 1 + patches.def.h | 6 ++++++ 7 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 patch/transferall.c create mode 100644 patch/transferall.h diff --git a/README.md b/README.md index ca4f19d..3848afe 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: -2020-02-02 - Added fsignal patch and moved dwmc signal settings to config.def.h +2020-02-02 - Added fsignal and transferall patches 2020-01-29 - Added swapfocus and shiftview patches @@ -345,6 +345,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [transfer](https://dwm.suckless.org/patches/transfer/) - lets you transfer the currently focused client between the master and stack area while increasing or decreasing the master area (nmaster) accordingly + - [transferall](https://dwm.suckless.org/patches/transfer/) + - lets you transfer all clients between the master and stack area while increasing or decreasing the master area (nmaster) accordingly + - [unfloatvisible](https://dwm.suckless.org/patches/unfloatvisible/) - resets isfloating on any visible windows that have it set and optionally also applies a layout diff --git a/config.def.h b/config.def.h index dc5e608..3896b45 100644 --- a/config.def.h +++ b/config.def.h @@ -604,6 +604,9 @@ static Key keys[] = { #if TRANSFER_PATCH { MODKEY, XK_x, transfer, {0} }, #endif // TRANSFER_PATCH + #if TRANSFER_ALL_PATCH + { MODKEY|ControlMask, XK_x, transferall, {0} }, + #endif // TRANSFER_ALL_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 0b3c0d5..78177b3 100644 --- a/patch/include.c +++ b/patch/include.c @@ -131,6 +131,9 @@ #if TRANSFER_PATCH #include "transfer.c" #endif +#if TRANSFER_ALL_PATCH +#include "transferall.c" +#endif #if UNFLOATVISIBLE_PATCH #include "unfloatvisible.c" #endif diff --git a/patch/include.h b/patch/include.h index 96f9a4b..d728729 100644 --- a/patch/include.h +++ b/patch/include.h @@ -131,6 +131,9 @@ #if TRANSFER_PATCH #include "transfer.h" #endif +#if TRANSFER_ALL_PATCH +#include "transferall.h" +#endif #if UNFLOATVISIBLE_PATCH #include "unfloatvisible.h" #endif diff --git a/patch/transferall.c b/patch/transferall.c new file mode 100644 index 0000000..fe12699 --- /dev/null +++ b/patch/transferall.c @@ -0,0 +1,25 @@ +void +transferall(const Arg *arg) +{ + Client *c, *n = selmon->clients, *attachfrom = NULL; + int i = 0, nstackclients = 0; + while (n) { + c = n; + n = c->next; + if (!ISVISIBLE(c) || c->isfloating) continue; + if (i >= selmon->nmaster) { + detach(c); + if (!attachfrom) { + attach(c); + } else { + c->next = attachfrom->next; + attachfrom->next = c; + } + attachfrom = c; + nstackclients++; + } + i++; + } + selmon->nmaster = nstackclients; + arrange(selmon); +} \ No newline at end of file diff --git a/patch/transferall.h b/patch/transferall.h new file mode 100644 index 0000000..5556468 --- /dev/null +++ b/patch/transferall.h @@ -0,0 +1 @@ +static void transferall(const Arg *arg); \ No newline at end of file diff --git a/patches.def.h b/patches.def.h index 5be35b2..3313bf7 100644 --- a/patches.def.h +++ b/patches.def.h @@ -538,6 +538,12 @@ */ #define TRANSFER_PATCH 0 +/* Lets you transfer all clients between the master and stack area + * while increasing or decreasing the master area (nmaster) accordingly. + * https://dwm.suckless.org/patches/transfer/ + */ +#define TRANSFER_ALL_PATCH 0 + /* This patch resets isfloating on any visible windows that have it set. * Optionally also applies a layout. * https://dwm.suckless.org/patches/unfloatvisible/