removed VRATIO, NMASTER, inc*(), renamed HRATIO into MASTER, see mailinglist for details aa53e39e
Anselm R. Garbe · 2007-08-10 18:16 8 file(s) · +90 −197
client.c +3 −3
230 230
	setclientstate(c, IconicState);
231 231
	c->isbanned = True;
232 232
	focus(c);
233 -
	lt->arrange();
233 +
	lt->arrange(NULL);
234 234
}
235 235
236 236
void
305 305
	sel->isfloating = !sel->isfloating;
306 306
	if(sel->isfloating)
307 307
		resize(sel, sel->x, sel->y, sel->w, sel->h, True);
308 -
	lt->arrange();
308 +
	lt->arrange(NULL);
309 309
}
310 310
311 311
void
337 337
	XSync(dpy, False);
338 338
	XSetErrorHandler(xerror);
339 339
	XUngrabServer(dpy);
340 -
	lt->arrange();
340 +
	lt->arrange(NULL);
341 341
}
342 342
343 343
void
config.arg.h +4 −9
24 24
};
25 25
26 26
/* layout(s) */
27 +
void tile(const char *arg);		/* arranges all windows tiled */
27 28
#define LAYOUTS \
28 29
static Layout layout[] = { \
29 30
	/* symbol		function */ \
30 31
	{ "[]=",		tile }, /* first entry is default */ \
31 32
	{ "><>",		floating }, \
32 33
};
33 -
#define NMASTER			1	/* clients in master area */
34 -
#define HRATIO			.8	/* horizontal ratio of tile */
35 -
#define VRATIO			.9	/* vertical ratio of tile */
34 +
#define MASTER			0.6	/* 0.1 .. 0.9 */
36 35
#define SNAP			32	/* snap pixel */
37 36
38 37
/* key definitions */
47 46
		"exec urxvtcd -tr -bg '#111' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \
48 47
	{ MODKEY,			XK_space,	setlayout,	NULL }, \
49 48
	{ MODKEY,			XK_b,		togglebar,	NULL }, \
50 -
	{ MODKEY,			XK_h,		incnmaster,	"1" }, \
51 -
	{ MODKEY,			XK_l,		incnmaster,	"-1" }, \
49 +
	{ MODKEY,			XK_h,		tile,		"-0.05" }, \
52 50
	{ MODKEY,			XK_j,		focusclient,	"1" }, \
53 51
	{ MODKEY,			XK_k,		focusclient,	"-1" }, \
54 -
	{ MODKEY|ShiftMask,		XK_h,		inchratio,	".1" }, \
55 -
	{ MODKEY|ShiftMask,		XK_l,		inchratio,	"-.1" }, \
56 -
	{ MODKEY|ShiftMask,		XK_j,		incvratio,	"-.1" }, \
57 -
	{ MODKEY|ShiftMask,		XK_k,		incvratio,	".1" }, \
52 +
	{ MODKEY,			XK_l,		tile,		"0.05" }, \
58 53
	{ MODKEY,			XK_m,		togglemax,	NULL }, \
59 54
	{ MODKEY,			XK_Return,	zoom,		NULL }, \
60 55
	{ MODKEY|ShiftMask,		XK_space,	togglefloating,	NULL }, \
config.default.h +4 −9
25 25
};
26 26
27 27
/* layout(s) */
28 +
void tile(const char *arg);		/* arranges all windows tiled */
28 29
#define LAYOUTS \
29 30
static Layout layout[] = { \
30 31
	/* symbol		function */ \
31 32
	{ "[]=",		tile }, /* first entry is default */ \
32 33
	{ "><>",		floating }, \
33 34
};
34 -
#define NMASTER			1	/* clients in master area */
35 -
#define HRATIO			.8	/* horizontal ratio of tile */
36 -
#define VRATIO			1	/* vertical ratio of tile */
35 +
#define MASTER			0.6	/* 0.1 .. 0.9 */
37 36
#define SNAP			32	/* snap pixel */
38 37
39 38
/* key definitions */
45 44
	{ MODKEY,			XK_p,		spawn, 		"exe=`dmenu_path | dmenu` && exec $exe" }, \
46 45
	{ MODKEY,			XK_space,	setlayout,	NULL }, \
47 46
	{ MODKEY,			XK_b,		togglebar,	NULL }, \
48 -
	{ MODKEY,			XK_h,		incnmaster,	"1" }, \
49 -
	{ MODKEY,			XK_l,		incnmaster,	"-1" }, \
47 +
	{ MODKEY,			XK_h,		tile,		"-0.05" }, \
50 48
	{ MODKEY,			XK_j,		focusclient,	"1" }, \
51 49
	{ MODKEY,			XK_k,		focusclient,	"-1" }, \
52 -
	{ MODKEY|ShiftMask,		XK_h,		inchratio,	".1" }, \
53 -
	{ MODKEY|ShiftMask,		XK_l,		inchratio,	"-.1" }, \
54 -
	{ MODKEY|ShiftMask,		XK_j,		incvratio,	"-.1" }, \
55 -
	{ MODKEY|ShiftMask,		XK_k,		incvratio,	".1" }, \
50 +
	{ MODKEY,			XK_l,		tile,		"0.05" }, \
56 51
	{ MODKEY,			XK_m,		togglemax,	NULL }, \
57 52
	{ MODKEY,			XK_Return,	zoom,		NULL }, \
58 53
	{ MODKEY|ShiftMask,		XK_space,	togglefloating,	NULL }, \
dwm.1 +5 −17
10 10
environment for the application in use and the task performed.
11 11
.P
12 12
In tiled layout windows are managed in a master and stacking area. The master
13 -
area contains the windows which currently need most attention, whereas the
13 +
area contains the window which currently needs most attention, whereas the
14 14
stacking area contains all other windows. In floating layout windows can be
15 15
resized and moved freely. Dialog windows are always managed floating,
16 16
regardless of the layout applied.
62 62
.B Mod1\-b
63 63
Shows/hides the status bar.
64 64
.TP
65 +
.B Mod1\-h
66 +
Decreases the master area width about 5% (tiled layout only).
67 +
.TP
65 68
.B Mod1\-j
66 69
Focus next window.
67 70
.TP
68 71
.B Mod1\-k
69 72
Focus previous window.
70 73
.TP
71 -
.B Mod1\-h
72 -
Increase the number of windows in the master area (tiled layout only).
73 -
.TP
74 74
.B Mod1\-l
75 -
Decrease the number of windows in the master area (tiled layout only).
76 -
.TP
77 -
.B Mod1\-Shift\-k
78 -
Increase vertical tile ratio, effects tile heights (tiled layout only).
79 -
.TP
80 -
.B Mod1\-Shift\-j
81 -
Decrease vertical tile ratio, effects tile heights (tiled layout only).
82 -
.TP
83 -
.B Mod1\-Shift\-h
84 -
Increase horizontal tile ratio, effects master area width (tiled layout only).
85 -
.TP
86 -
.B Mod1\-Shift\-l
87 -
Decrease horizontal tile ratio, effects master area width (tiled layout only).
75 +
Increases the master area width about 5% (tiled layout only).
88 76
.TP
89 77
.B Mod1\-m
90 78
Toggles maximization of current window (floating layout only).
dwm.h +2 −5
76 76
77 77
typedef struct {
78 78
	const char *symbol;
79 -
	void (*arrange)(void);
79 +
	void (*arrange)(const char *);
80 80
} Layout;
81 81
82 82
extern const char *tags[];			/* all tags */
120 120
void grabkeys(void);			/* grab all keys defined in config.h */
121 121
122 122
/* layout.c */
123 -
void floating(void);			/* arranges all windows floating */
123 +
void floating(const char *arg);		/* arranges all windows floating */
124 124
void focusclient(const char *arg);	/* focuses next(1)/previous(-1) visible client */
125 -
void inchratio(const char *arg);	/* increments the horizontal tile ratio with arg's value */
126 -
void incvratio(const char *arg);	/* increments the vertical tile ratio with arg's value */
127 -
void incnmaster(const char *arg);	/* increments nmaster with arg's index value */
128 125
void initlayouts(void);			/* initialize layout array */
129 126
Client *nexttiled(Client *c);		/* returns tiled successor of c */
130 127
void restack(void);			/* restores z layers of all clients */
event.c +2 −2
216 216
		dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
217 217
		XResizeWindow(dpy, barwin, sw, bh);
218 218
		updatebarpos();
219 -
		lt->arrange();
219 +
		lt->arrange(NULL);
220 220
	}
221 221
}
222 222
317 317
			case XA_WM_TRANSIENT_FOR:
318 318
				XGetTransientForHint(dpy, c->win, &trans);
319 319
				if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
320 -
					lt->arrange();
320 +
					lt->arrange(NULL);
321 321
				break;
322 322
			case XA_WM_NORMAL_HINTS:
323 323
				updatesizehints(c);
layout.c +66 −148
8 8
9 9
/* static */
10 10
11 -
static double hratio = HRATIO;
12 -
static double vratio = VRATIO;
13 11
static unsigned int nlayouts = 0;
14 -
static unsigned int nmaster = NMASTER;
15 -
16 -
static double /* simple pow() */
17 -
spow(double x, double y)
18 -
{
19 -
	if(y == 0)
20 -
		return 1;
21 -
	while(--y)
22 -
		x *= x;
23 -
	return x;
24 -
}
25 -
26 -
static void
27 -
tile(void) {
28 -
	Bool mmaxtile = False, smaxtile = False; /* fallback tiling */
29 -
	double mscale = 0, sscale = 0, sum = 0;
30 -
	unsigned int i, n, nx, ny, nw, nh, mw, tw;
31 -
	Client *c;
32 -
33 -
	/* preparation */
34 -
	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
35 -
		n++;
36 -
	nx = wax;
37 -
	ny = way;
38 -
	mw = (n <= nmaster) ? waw :  waw / (1 + hratio);
39 -
	tw = waw - mw;
40 -
	if(n > 0) {
41 -
		if(n <= nmaster) {
42 -
			for(i = 0; i < n; i++)
43 -
				sum += spow(vratio, i);
44 -
			mscale = wah / sum;
45 -
			if(vratio >= 1)
46 -
				mmaxtile = bh > mscale;
47 -
			else
48 -
				mmaxtile = bh > (mscale * spow(vratio, n - 1));
49 -
		}
50 -
		else {
51 -
			for(i = 0; i < nmaster; i++)
52 -
				sum += spow(vratio, i);
53 -
			mscale = wah / sum;
54 -
			for(sum = 0, i = 0; i < (n - nmaster); i++)
55 -
				sum += spow(vratio, i);
56 -
			sscale = wah / sum;
57 -
			if(vratio >= 1) {
58 -
				mmaxtile = bh > mscale;
59 -
				smaxtile = bh > sscale;
60 -
			}
61 -
			else {
62 -
				mmaxtile = bh > (mscale * spow(vratio, nmaster - 1));
63 -
				smaxtile = bh > (sscale * spow(vratio, n - nmaster - 1));
64 -
			}
65 -
		}
66 -
	}
67 -
	/* tiling */
68 -
	for(i = 0, c = clients; c; c = c->next)
69 -
		if(isvisible(c)) {
70 -
			unban(c);
71 -
			if(c->isfloating)
72 -
				continue;
73 -
			c->ismax = False;
74 -
			if(i < nmaster) { /* master window */
75 -
				nw = mw - 2 * c->border;
76 -
				if(mmaxtile) {
77 -
					ny = way;
78 -
					nh = wah - 2 * c->border;
79 -
				}
80 -
				else if(i + 1 == (n < nmaster ? n : nmaster))
81 -
					nh = (way + wah) - ny - 2 * c->border;
82 -
				else
83 -
					nh = (mscale * spow(vratio, i)) - 2 * c->border;
84 -
			}
85 -
			else { /* tile window */
86 -
				nw = tw - 2 * c->border;
87 -
				if(i == nmaster) {
88 -
					ny = way;
89 -
					nx = wax + mw;
90 -
				}
91 -
				if(smaxtile) {
92 -
					ny = way;
93 -
					nh = wah - 2 * c->border;
94 -
				}
95 -
				else if(i + 1 == n)
96 -
					nh = (way + wah) - ny - 2 * c->border;
97 -
				else
98 -
					nh = (sscale * spow(vratio, i - nmaster)) - 2 * c->border;
99 -
			}
100 -
			resize(c, nx, ny, nw, nh, False);
101 -
			ny += nh;
102 -
			i++;
103 -
		}
104 -
		else
105 -
			ban(c);
106 -
	focus(NULL);
107 -
	restack();
108 -
}
109 12
110 13
LAYOUTS
111 14
112 -
static void
113 -
incratio(const char *arg, double *ratio, double def) {
114 -
	double delta;
115 -
116 -
	if(lt->arrange != tile)
117 -
		return;
118 -
	if(!arg)
119 -
		*ratio = def;
120 -
	else {
121 -
		if(1 == sscanf(arg, "%lf", &delta)) {
122 -
			if(delta + (*ratio) < .1 || delta + (*ratio) > 1.9)
123 -
				return;
124 -
			*ratio += delta;
125 -
		}
126 -
	}
127 -
	lt->arrange();
128 -
}
129 -
130 15
/* extern */
131 16
132 17
void
133 -
floating(void) {
18 +
floating(const char *arg) {
134 19
	Client *c;
20 +
21 +
	if(lt->arrange != floating)
22 +
		return;
135 23
136 24
	for(c = clients; c; c = c->next)
137 25
		if(isvisible(c)) {
169 57
}
170 58
171 59
void
172 -
inchratio(const char *arg) {
173 -
	incratio(arg, &hratio, HRATIO);
174 -
}
175 -
176 -
void
177 -
incvratio(const char *arg) {
178 -
	incratio(arg, &vratio, VRATIO);
179 -
}
180 -
181 -
void
182 -
incnmaster(const char *arg) {
183 -
	int i;
184 -
185 -
	if(!arg)
186 -
		nmaster = NMASTER;
187 -
	else {
188 -
		i = atoi(arg);
189 -
		if((lt->arrange != tile) || (nmaster + i < 1)
190 -
		|| (wah / (nmaster + i) <= 2 * BORDERPX))
191 -
			return;
192 -
		nmaster += i;
193 -
	}
194 -
	if(sel)
195 -
		lt->arrange();
196 -
	else
197 -
		drawstatus();
198 -
}
199 -
200 -
void
201 60
initlayouts(void) {
202 61
	unsigned int i, w;
203 62
261 120
		lt = &layout[i];
262 121
	}
263 122
	if(sel)
264 -
		lt->arrange();
123 +
		lt->arrange(NULL);
265 124
	else
266 125
		drawstatus();
267 126
}
268 127
269 128
void
129 +
tile(const char *arg) {
130 +
	static double master = MASTER;
131 +
	double delta;
132 +
	unsigned int i, n, nx, ny, nw, nh, mw, th;
133 +
	Client *c;
134 +
135 +
	if(lt->arrange != tile)
136 +
		return;
137 +
138 +
	/* arg handling, manipulate master */
139 +
	if(arg && (1 == sscanf(arg, "%lf", &delta))) {
140 +
		if(delta + master > 0.1 && delta + master < 0.9)
141 +
			master += delta;
142 +
	}
143 +
144 +
	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
145 +
		n++;
146 +
147 +
	/* window geoms */
148 +
	mw = (n == 1) ? waw : master * waw;
149 +
	th = (n > 1) ? wah / (n - 1) : 0;
150 +
	if(n > 1 && th < bh)
151 +
		th = wah;
152 +
153 +
	nx = wax;
154 +
	ny = way;
155 +
	for(i = 0, c = clients; c; c = c->next)
156 +
		if(isvisible(c)) {
157 +
			unban(c);
158 +
			if(c->isfloating)
159 +
				continue;
160 +
			c->ismax = False;
161 +
			if(i == 0) { /* master */
162 +
				nw = mw - 2 * c->border;
163 +
				nh = wah - 2 * c->border;
164 +
			}
165 +
			else {  /* tile window */
166 +
				if(i == 1) {
167 +
					ny = way;
168 +
					nx += mw;
169 +
				}
170 +
				nw = waw - mw - 2 * c->border;
171 +
				if(i + 1 == n) /* remainder */
172 +
					nh = (way + wah) - ny - 2 * c->border;
173 +
				else
174 +
					nh = th - 2 * c->border;
175 +
			}
176 +
			resize(c, nx, ny, nw, nh, False);
177 +
			if(n > 1 && th != wah)
178 +
				ny += nh;
179 +
			i++;
180 +
		}
181 +
		else
182 +
			ban(c);
183 +
	focus(NULL);
184 +
	restack();
185 +
}
186 +
187 +
void
270 188
togglebar(const char *arg) {
271 189
	if(bpos == BarOff)
272 190
		bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
273 191
	else
274 192
		bpos = BarOff;
275 193
	updatebarpos();
276 -
	lt->arrange();
194 +
	lt->arrange(NULL);
277 195
}
278 196
279 197
void
307 225
	detach(c);
308 226
	attach(c);
309 227
	focus(c);
310 -
	lt->arrange();
228 +
	lt->arrange(NULL);
311 229
}
tag.c +4 −4
110 110
	i = arg ? atoi(arg) : 0;
111 111
	if(i >= 0 && i < ntags)
112 112
		sel->tags[i] = True;
113 -
	lt->arrange();
113 +
	lt->arrange(NULL);
114 114
}
115 115
116 116
void
124 124
	for(j = 0; j < ntags && !sel->tags[j]; j++);
125 125
	if(j == ntags)
126 126
		sel->tags[i] = True;
127 -
	lt->arrange();
127 +
	lt->arrange(NULL);
128 128
}
129 129
130 130
void
136 136
	for(j = 0; j < ntags && !seltag[j]; j++);
137 137
	if(j == ntags)
138 138
		seltag[i] = True; /* cannot toggle last view */
139 -
	lt->arrange();
139 +
	lt->arrange(NULL);
140 140
}
141 141
142 142
void
148 148
	i = arg ? atoi(arg) : 0;
149 149
	if(i >= 0 && i < ntags)
150 150
		seltag[i] = True;
151 -
	lt->arrange();
151 +
	lt->arrange(NULL);
152 152
}