[wiki] [sites] [dwm][patch] transfer: Add transferall patch variant || Miles Alan

From: <git_AT_suckless.org>
Date: Sat, 01 Feb 2020 17:29:17 +0100

commit d24fb1fbeb8d9a5baed3bf3e6b58a0c84426547e
Author: Miles Alan <m_AT_milesalan.com>
Date: Sat Feb 1 10:27:20 2020 -0600

    [dwm][patch] transfer: Add transferall patch variant

diff --git a/dwm.suckless.org/patches/transfer/dwm-transferall-6.2.diff b/dwm.suckless.org/patches/transfer/dwm-transferall-6.2.diff
new file mode 100644
index 00000000..a5c52788
--- /dev/null
+++ b/dwm.suckless.org/patches/transfer/dwm-transferall-6.2.diff
_AT_@ -0,0 +1,74 @@
+From 43d8a0f3df28ba0b25b85eb38b0f990b9947c48a Mon Sep 17 00:00:00 2001
+From: Miles Alan <m_AT_milesalan.com>
+Date: Sat, 1 Feb 2020 09:55:43 -0600
+Subject: [PATCH] Add transferall function which swaps the master & stack and
+ adjusts nmaster.
+
+All stack clients after the function is run are moved into the master area
+and master clients are moved into the stack area. The new nmaster will be
+adjusted to be equal to the old number of clients in the stack (e.g. the
+new number of clients in the master).
+---
+ config.def.h | 1 +
+ dwm.c | 26 ++++++++++++++++++++++++++
+ 2 files changed, 27 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..cce5b64 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -70,6 +70,7 @@ static Key keys[] = {
+ { MODKEY, XK_d, incnmaster, {.i = -1 } },
+ { MODKEY, XK_h, setmfact, {.f = -0.05} },
+ { MODKEY, XK_l, setmfact, {.f = +0.05} },
++ { MODKEY, XK_z, transferall, {0} },
+ { MODKEY, XK_Return, zoom, {0} },
+ { MODKEY, XK_Tab, view, {0} },
+ { MODKEY|ShiftMask, XK_c, killclient, {0} },
+diff --git a/dwm.c b/dwm.c
+index 4465af1..a8864e9 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -213,6 +213,7 @@ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
++static void transferall(const Arg *arg);
+ static void unfocus(Client *c, int setfocus);
+ static void unmanage(Client *c, int destroyed);
+ static void unmapnotify(XEvent *e);
+_AT_@ -1746,6 +1747,31 @@ toggleview(const Arg *arg)
+ }
+ }
+
++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);
++}
++
+ void
+ unfocus(Client *c, int setfocus)
+ {
+--
+2.23.1
+
diff --git a/dwm.suckless.org/patches/transfer/index.md b/dwm.suckless.org/patches/transfer/index.md
index 06092d6f..f9ca1f84 100644
--- a/dwm.suckless.org/patches/transfer/index.md
+++ b/dwm.suckless.org/patches/transfer/index.md
_AT_@ -1,14 +1,25 @@
 # transfer
 
-This patch adds a keybinding that lets you transfer the currently focused
-client between the master and the stack and readjusts the nmaster variable
-accordingly. For example, if you're focused on a stack client, using the
-transfer function moves the client to the master area and increments
-nmaster by 1. Conversely if you're focused on a master client and call
-transfer, the client is moved to the stack and nmaster is decremented by 1.
+These two patches, transfer and transferall, let you transfer clients
+between the master and stack while automatically adjusting nmaster.
+These are two independent patches which can be used separately.
+
+The transfer patch adds a function that lets you transfer the currently
+focused client between the master and the stack boundry and auto
+increments or decrements nmaster accordingly. For example, if you're
+focused on a stack client, using the transfer function moves the client
+to the master area and increments nmaster by 1. Conversely if you're
+focused on a master client and call transfer, the client is moved to
+the stack and nmaster is decremented by 1.
+
+The transferall patch adds a function that lets you transfer all
+clients in the master into the stack and stack clients into the master;
+effectively swapping the master and the stack. The new nmaster is adjusted
+to be the old number of clients in the stack.
 
 ## Download
 * [dwm-transfer-6.2.diff](dwm-transfer-6.2.diff) (01/25/2020)
+* [dwm-transferall-6.2.diff](dwm-transferall-6.2.diff) (02/01/2020)
 
 ## Author
 - Miles Alan (m_AT_milesalan.com)
Received on Sat Feb 01 2020 - 17:29:17 CET

This archive was generated by hypermail 2.3.0 : Sat Feb 01 2020 - 17:36:34 CET