dwm-transferall-6.2.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-transferall-6.2.diff (2305B)
---
1 From 43d8a0f3df28ba0b25b85eb38b0f990b9947c48a Mon Sep 17 00:00:00 2001
2 From: Miles Alan <m@milesalan.com>
3 Date: Sat, 1 Feb 2020 09:55:43 -0600
4 Subject: [PATCH] Add transferall function which swaps the master & stack and
5 adjusts nmaster.
6
7 All stack clients after the function is run are moved into the master area
8 and master clients are moved into the stack area. The new nmaster will be
9 adjusted to be equal to the old number of clients in the stack (e.g. the
10 new number of clients in the master).
11 ---
12 config.def.h | 1 +
13 dwm.c | 26 ++++++++++++++++++++++++++
14 2 files changed, 27 insertions(+)
15
16 diff --git a/config.def.h b/config.def.h
17 index 1c0b587..cce5b64 100644
18 --- a/config.def.h
19 +++ b/config.def.h
20 @@ -70,6 +70,7 @@ static Key keys[] = {
21 { MODKEY, XK_d, incnmaster, {.i = -1 } },
22 { MODKEY, XK_h, setmfact, {.f = -0.05} },
23 { MODKEY, XK_l, setmfact, {.f = +0.05} },
24 + { MODKEY, XK_z, transferall, {0} },
25 { MODKEY, XK_Return, zoom, {0} },
26 { MODKEY, XK_Tab, view, {0} },
27 { MODKEY|ShiftMask, XK_c, killclient, {0} },
28 diff --git a/dwm.c b/dwm.c
29 index 4465af1..a8864e9 100644
30 --- a/dwm.c
31 +++ b/dwm.c
32 @@ -213,6 +213,7 @@ static void togglebar(const Arg *arg);
33 static void togglefloating(const Arg *arg);
34 static void toggletag(const Arg *arg);
35 static void toggleview(const Arg *arg);
36 +static void transferall(const Arg *arg);
37 static void unfocus(Client *c, int setfocus);
38 static void unmanage(Client *c, int destroyed);
39 static void unmapnotify(XEvent *e);
40 @@ -1746,6 +1747,31 @@ toggleview(const Arg *arg)
41 }
42 }
43
44 +void
45 +transferall(const Arg *arg) {
46 + Client *c, *n = selmon->clients, *attachfrom = NULL;
47 + int i = 0, nstackclients = 0;
48 + while (n) {
49 + c = n;
50 + n = c->next;
51 + if (!ISVISIBLE(c) || c->isfloating) continue;
52 + if (i >= selmon->nmaster) {
53 + detach(c);
54 + if (!attachfrom) {
55 + attach(c);
56 + } else {
57 + c->next = attachfrom->next;
58 + attachfrom->next = c;
59 + }
60 + attachfrom = c;
61 + nstackclients++;
62 + }
63 + i++;
64 + }
65 + selmon->nmaster = nstackclients;
66 + arrange(selmon);
67 +}
68 +
69 void
70 unfocus(Client *c, int setfocus)
71 {
72 --
73 2.23.1
74