summaryrefslogtreecommitdiff
path: root/dwm/patches/dwm-toggleallmonspertag-6.4.diff
blob: 32527f69b847b934d1f0c85f23063e580add0565 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
diff --git a/config.def.h b/config.def.h
index 061ad66..67afc6d 100644
--- a/config.def.h
+++ b/config.def.h
@@ -71,6 +71,7 @@ static const Key keys[] = {
 	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
 	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
 	{ MODKEY,                       XK_Return, zoom,           {0} },
+	{ MODKEY|ShiftMask,             XK_Tab,    toggleall,      {0} },
 	{ MODKEY,                       XK_Tab,    view,           {0} },
 	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
 	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
diff --git a/dwm.c b/dwm.c
index e5efb6a..62f711b 100644
--- a/dwm.c
+++ b/dwm.c
@@ -210,6 +210,7 @@ static void spawn(const Arg *arg);
 static void tag(const Arg *arg);
 static void tagmon(const Arg *arg);
 static void tile(Monitor *m);
+static void toggleall(const Arg *arg);
 static void togglebar(const Arg *arg);
 static void togglefloating(const Arg *arg);
 static void toggletag(const Arg *arg);
@@ -1694,6 +1695,49 @@ tile(Monitor *m)
 		}
 }
 
+
+void
+toggleall(const Arg *arg)
+{
+	int i;
+	unsigned int tmptag;
+
+	Monitor* m;
+	for(m = mons; m; m = m->next){
+
+		if ((arg->ui & TAGMASK) == m->tagset[m->seltags])
+			return;
+		m->seltags ^= 1; /* toggle sel tagset */
+		if (arg->ui & TAGMASK) {
+			m->tagset[m->seltags] = arg->ui & TAGMASK;
+			m->pertag->prevtag = m->pertag->curtag;
+
+			if (arg->ui == ~0)
+				m->pertag->curtag = 0;
+			else {
+				for (i = 0; !(arg->ui & 1 << i); i++) ;
+				m->pertag->curtag = i + 1;
+			}
+		} else {
+			tmptag = m->pertag->prevtag;
+			m->pertag->prevtag = m->pertag->curtag;
+			m->pertag->curtag = tmptag;
+		}
+
+		m->nmaster = m->pertag->nmasters[m->pertag->curtag];
+		m->mfact = m->pertag->mfacts[m->pertag->curtag];
+		m->sellt = m->pertag->sellts[m->pertag->curtag];
+		m->lt[m->sellt] = m->pertag->ltidxs[m->pertag->curtag][m->sellt];
+		m->lt[m->sellt^1] = m->pertag->ltidxs[m->pertag->curtag][m->sellt^1];
+
+		if (m->showbar != m->pertag->showbars[m->pertag->curtag])
+			togglebar(NULL);
+
+		focus(NULL);
+		arrange(m);
+	}
+}
+
 void
 togglebar(const Arg *arg)
 {