about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-01-05 14:48:16 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-01-05 14:48:16 +0100
commit06bae9dfb7902c97877f3493cf4b489ccf531089 (patch)
tree41e684607936b951f00dab79e1a2cb7c0cefe2be
parent0b80d1842d1c921a8a94c11fd9222dad9311cc97 (diff)
downloaddwm-06bae9dfb7902c97877f3493cf4b489ccf531089.tar.gz
added MODKEY-{plus,minus} shortcuts (increasing/decreasing master clients)
-rw-r--r--config.arg.h4
-rw-r--r--config.default.h2
-rw-r--r--dwm.16
-rw-r--r--view.c65
4 files changed, 62 insertions, 15 deletions
diff --git a/config.arg.h b/config.arg.h
index d889d96..5167fea 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -31,13 +31,13 @@ static Key key[] = { \
 		{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
 			" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
 			"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
-	{ MODKEY,			XK_d,		incnmaster,	{ .i = -1 } }, \
 	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \
 	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \
 	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
 	{ MODKEY,			XK_g,		resizemaster,	{ .i = 15 } }, \
-	{ MODKEY,			XK_i,		incnmaster,	{ .i = 1 } }, \
 	{ MODKEY,			XK_s,		resizemaster,	{ .i = -15 } }, \
+	{ MODKEY,			XK_plus,	incnmaster,	{ .i = 1 } }, \
+	{ MODKEY,			XK_minus,	incnmaster,	{ .i = -1 } }, \
 	{ MODKEY|ShiftMask,		XK_0,		tag,		{ .i = -1 } }, \
 	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \
 	{ MODKEY|ShiftMask,		XK_2,		tag,		{ .i = 1 } }, \
diff --git a/config.default.h b/config.default.h
index 5b08f93..2015177 100644
--- a/config.default.h
+++ b/config.default.h
@@ -31,6 +31,8 @@ static Key key[] = { \
 	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
 	{ MODKEY,			XK_g,		resizemaster,	{ .i = 15 } }, \
 	{ MODKEY,			XK_s,		resizemaster,	{ .i = -15 } }, \
+	{ MODKEY,			XK_plus,	incnmaster,	{ .i = 1 } }, \
+	{ MODKEY,			XK_minus,	incnmaster,	{ .i = -1 } }, \
 	{ MODKEY|ShiftMask,		XK_0,		tag,		{ .i = -1 } }, \
 	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \
 	{ MODKEY|ShiftMask,		XK_2,		tag,		{ .i = 1 } }, \
diff --git a/dwm.1 b/dwm.1
index 6eead84..8742fa8 100644
--- a/dwm.1
+++ b/dwm.1
@@ -70,6 +70,12 @@ Grow master area (tiling mode only).
 .B Mod1-s
 Shrink master area (tiling mode only).
 .TP
+.B Mod1-plus
+Increase clients of master area (tiling mode only).
+.TP
+.B Mod1-minus
+Decrease clients of master area (tiling mode only).
+.TP
 .B Mod1-Shift-[1..n]
 Apply
 .RB nth
diff --git a/view.c b/view.c
index 1ac3141..2143d70 100644
--- a/view.c
+++ b/view.c
@@ -11,6 +11,40 @@ nexttiled(Client *c) {
 	return c;
 }
 
+static Bool
+ismaster(Client *c) {
+	Client *cl;
+	unsigned int i;
+
+	for(cl = nexttiled(clients), i = 0; cl && cl != c; cl = nexttiled(cl->next), i++);
+	return i < nmaster;
+}
+
+static void
+pop(Client *c) {
+	detach(c);
+	if(clients)
+		clients->prev = c;
+	c->next = clients;
+	clients = c;
+}
+
+static void
+swap(Client *c1, Client *c2) {
+	Client tmp = *c1;
+	Client *cp = c1->prev;
+	Client *cn = c1->next;
+
+	*c1 = *c2;
+	c1->prev = cp;
+	c1->next = cn;
+	cp = c2->prev;
+	cn = c2->next;
+	*c2 = tmp;
+	c2->prev = cp;
+	c2->next = cn;
+}
+
 static void
 togglemax(Client *c) {
 	XEvent ev;
@@ -34,6 +68,15 @@ togglemax(Client *c) {
 	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
 }
 
+static Client *
+topofstack() {
+	Client *c;
+	unsigned int i;
+
+	for(c = nexttiled(clients), i = 0; c && i < nmaster; c = nexttiled(c->next), i++);
+	return (i < nmaster) ? NULL : c;
+}
+
 /* extern */
 
 void (*arrange)(void) = DEFMODE;
@@ -248,7 +291,7 @@ view(Arg *arg) {
 
 void
 zoom(Arg *arg) {
-	unsigned int i, n;
+	unsigned int n;
 	Client *c;
 
 	if(!sel)
@@ -262,19 +305,15 @@ zoom(Arg *arg) {
 	if(n <= nmaster || (arrange == dofloat))
 		return;
 
-	for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next))
-		i++;
-	if(c == sel && i < nmaster)
-		for(; c && i < nmaster; c = nexttiled(c->next))
-			i++;
-	if(!c)
-		return;
+	if(ismaster((c = sel))) {
+		if(!(c = topofstack()))
+			return;
+		swap(c, sel);
+		c = sel;
+	}
+	else
+		pop(c);
 
-	detach(c);
-	if(clients)
-		clients->prev = c;
-	c->next = clients;
-	clients = c;
 	focus(c);
 	arrange();
 }
ef='/akkartik/mu/commit/subx/014index_addressing.cc?h=main&id=836d13dbc92c97cf529d6a51972be350e8ee1b2c'>836d13db ^
4a943d4e ^




















0e87e934 ^
4a943d4e ^


















d1df4aca ^


4a943d4e ^





















d1df4aca ^







4a943d4e ^





















d1df4aca ^




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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155