about summary refs log tree commit diff stats
path: root/dwm.c
diff options
context:
space:
mode:
authorAnselm R Garbe <garbeam@gmail.com>2008-05-26 10:10:33 +0100
committerAnselm R Garbe <garbeam@gmail.com>2008-05-26 10:10:33 +0100
commit9189f7a12dce4e3b38341e0704cca257994ab2ba (patch)
treecf2fe842cb96e40a0ee7752e3738fbcf5dd8176c /dwm.c
parent2d4faae522668ad30cd512963d1982e591a183ab (diff)
downloaddwm-9189f7a12dce4e3b38341e0704cca257994ab2ba.tar.gz
simplified tile()
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c52
1 files changed, 15 insertions, 37 deletions
diff --git a/dwm.c b/dwm.c
index 0e4703e..2fe70e4 100644
--- a/dwm.c
+++ b/dwm.c
@@ -170,7 +170,6 @@ void spawn(const void *arg);
 void tag(const void *arg);
 uint textnw(const char *text, uint len);
 void tile(void);
-void tileresize(Client *c, int x, int y, int w, int h);
 void togglebar(const void *arg);
 void togglefloating(const void *arg);
 void togglelayout(const void *arg);
@@ -1123,6 +1122,10 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
 		x = sx;
 	if(y + h + 2 * c->bw < sy)
 		y = sy;
+	if(h < bh)
+		h = bh;
+	if(w < bh)
+		w = bh;
 	if(c->x != x || c->y != y || c->w != w || c->h != h || c->isbanned || c->ismax) {
 		c->isbanned = c->ismax = False;
 		c->x = wc.x = x;
@@ -1435,7 +1438,7 @@ textnw(const char *text, uint len) {
 
 void
 tile(void) {
-	int x, y, h, w, mx, my, mw, mh, tx, ty, tw, th;
+	int x, y, h, w, mw;
 	uint i, n;
 	Client *c;
 
@@ -1443,56 +1446,31 @@ tile(void) {
 	if(n == 0)
 		return;
 
-	/* master area geometry */
-	mx = wx;
-	my = wy;
-	mw = mfact * ww;
-	mh = wh;
-
-	/* tile area geometry */
-	tx = mx + mw;
-	ty = wy;
-	tw = ww - mw;
-	th = wh;
-
 	/* master */
 	c = nexttiled(clients);
-
-	if(n == 1)
-		tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw);
-	else
-		tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw);
+	mw = mfact * ww;
+	resize(c, wx, wy, ((n == 1) ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints);
 
 	if(--n == 0)
 		return;
 
 	/* tile stack */
-	x = (tx > c->x + c->w) ? c->x + c->w + 2 * c->bw : tw;
-	y = ty;
-	w = (tx > c->x + c->w) ? wx + ww - x : tw;
-	h = th / n;
+	x = (wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : ww - mw;
+	y = wy;
+	w = (wx + mw > c->x + c->w) ? wx + ww - x : ww - mw;
+	h = wh / n;
 	if(h < bh)
-		h = th;
+		h = wh;
 
 	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
-		if(i + 1 == n) /* remainder */
-			tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw);
-		else
-			tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw);
-		if(h != th)
+		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
+		       ? (wy + wh) - y : h) - 2 * c->bw, resizehints);
+		if(h != wh)
 			y = c->y + c->h + 2 * c->bw;
 	}
 }
 
 void
-tileresize(Client *c, int x, int y, int w, int h) {
-	resize(c, x, y, w, h, resizehints);
-	if(resizehints && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
-		/* client doesn't accept size constraints */
-		resize(c, x, y, w, h, False);
-}
-
-void
 togglebar(const void *arg) {
 	showbar = !showbar;
 	updategeom();
0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-06-19 16:34:11 -0700 1599' href='/akkartik/mu/commit/045closure_name.cc?h=main&id=a91c1c2a28583262cc6052a5c3d9e713e9b4c0e0'>a91c1c2a ^
82ac0b7e ^



2199940a ^
82ac0b7e ^
363be37f ^
82ac0b7e ^




363be37f ^
ac0e9db5 ^
05d17773 ^
82ac0b7e ^
ac0e9db5 ^
ab6ed192 ^
0487a30e ^
ac0e9db5 ^
363be37f ^


35064671 ^
82ac0b7e ^

0487a30e ^
35064671 ^



e4630643 ^
0487a30e ^
82ac0b7e ^
363be37f ^
35064671 ^
82ac0b7e ^

35064671 ^
363be37f ^
82ac0b7e ^



82ac0b7e ^


363be37f ^

82ac0b7e ^
35064671 ^
82ac0b7e ^


35064671 ^
0f125d5f ^
82ac0b7e ^
363be37f ^


82ac0b7e ^




363be37f ^
82ac0b7e ^

35064671 ^
ac0e9db5 ^
35064671 ^
82ac0b7e ^
35064671 ^
82ac0b7e ^








363be37f ^
82ac0b7e ^

35064671 ^
82ac0b7e ^






ac0e9db5 ^

82ac0b7e ^

e4630643 ^



0487a30e ^
82ac0b7e ^


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