From 84b0361b65ab17d1b167ad9dbfcab0524ef4bfde Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 26 Jan 2020 07:32:00 +0100 Subject: [PATCH] Adding transfer patch --- README.md | 5 +++++ config.def.h | 3 +++ patch/include.c | 3 +++ patch/include.h | 3 +++ patch/transfer.c | 33 +++++++++++++++++++++++++++++++++ patch/transfer.h | 1 + patches.def.h | 6 ++++++ 7 files changed, 54 insertions(+) create mode 100644 patch/transfer.c create mode 100644 patch/transfer.h diff --git a/README.md b/README.md index 17055a3..a8ec577 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2020-01-26 - Added transfer patch + 2020-01-24 - Added barpadding patch (incl. statusallmons, statuspadding, statuscolors, systray, alpha, holdbar and extrabar patch compatibility). Moved patches.h to patches.def.h to mimic the config pattern of having default and personal settings. 2020-01-17 - Added inplacerotate patch @@ -325,6 +327,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [togglefullscreen](https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-togglefullscreen-6.2.diff) - allows you to toggle fullscreen on and off using a single shortcut key + - [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 + - [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 86169ff..1ad3d6b 100644 --- a/config.def.h +++ b/config.def.h @@ -559,6 +559,9 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, #endif // MOVESTACK_PATCH + #if TRANSFER_PATCH + { MODKEY, XK_x, transfer, {0} }, + #endif // TRANSFER_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 2e9cbf2..1fbc504 100644 --- a/patch/include.c +++ b/patch/include.c @@ -120,6 +120,9 @@ #if TOGGLEFULLSCREEN_PATCH #include "togglefullscreen.c" #endif +#if TRANSFER_PATCH +#include "transfer.c" +#endif #if UNFLOATVISIBLE_PATCH #include "unfloatvisible.c" #endif diff --git a/patch/include.h b/patch/include.h index 06f4f0a..efe0917 100644 --- a/patch/include.h +++ b/patch/include.h @@ -120,6 +120,9 @@ #if TOGGLEFULLSCREEN_PATCH #include "togglefullscreen.h" #endif +#if TRANSFER_PATCH +#include "transfer.h" +#endif #if UNFLOATVISIBLE_PATCH #include "unfloatvisible.h" #endif diff --git a/patch/transfer.c b/patch/transfer.c new file mode 100644 index 0000000..f667416 --- /dev/null +++ b/patch/transfer.c @@ -0,0 +1,33 @@ +void +transfer(const Arg *arg) +{ + Client *c, *mtail = selmon->clients, *stail = NULL, *insertafter; + int transfertostack = 0, i, nmasterclients; + + for (i = 0, c = selmon->clients; c; c = c->next) { + if (!ISVISIBLE(c) || c->isfloating) continue; + if (selmon->sel == c) { transfertostack = i < selmon->nmaster && selmon->nmaster != 0; } + if (i < selmon->nmaster) { nmasterclients++; mtail = c; } + stail = c; + i++; + } + if (selmon->sel->isfloating || i == 0) { + return; + } else if (transfertostack) { + selmon->nmaster = MIN(i, selmon->nmaster) - 1; + insertafter = stail; + } else { + selmon->nmaster = selmon->nmaster + 1; + insertafter = mtail; + } + if (insertafter != selmon->sel) { + detach(selmon->sel); + if (selmon->nmaster == 1 && !transfertostack) { + attach(selmon->sel); // Head prepend case + } else { + selmon->sel->next = insertafter->next; + insertafter->next = selmon->sel; + } + } + arrange(selmon); +} \ No newline at end of file diff --git a/patch/transfer.h b/patch/transfer.h new file mode 100644 index 0000000..a8436dd --- /dev/null +++ b/patch/transfer.h @@ -0,0 +1 @@ +static void transfer(const Arg *arg); \ No newline at end of file diff --git a/patches.def.h b/patches.def.h index 292763c..1477706 100644 --- a/patches.def.h +++ b/patches.def.h @@ -512,6 +512,12 @@ */ #define TOGGLEFULLSCREEN_PATCH 0 +/* Lets you transfer the currently focused client between the master and stack area + * while increasing or decreasing the master area (nmaster) accordingly. + * https://dwm.suckless.org/patches/transfer/ + */ +#define TRANSFER_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/