changed shortcuts as described on the mailinglist, added sanity checks for ratios during tile (fallback to wah if clients would get too small), documented that new stuff/shortcuts in dwm(1) 79692508
Anselm R. Garbe · 2007-08-05 12:47 4 file(s) · +60 −35
config.arg.h +7 −7
32 32
};
33 33
#define NMASTER			1	/* clients in master area */
34 34
#define HRATIO			.8	/* horizontal ratio of tile */
35 -
#define VRATIO			.8	/* vertical ratio of tile */
35 +
#define VRATIO			.9	/* vertical ratio of tile */
36 36
#define SNAP			32	/* snap pixel */
37 37
38 38
/* key definitions */
47 47
		"exec urxvtcd -tr -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \
48 48
	{ MODKEY,			XK_space,	setlayout,	NULL }, \
49 49
	{ MODKEY,			XK_b,		togglebar,	NULL }, \
50 -
	{ MODKEY,			XK_h,		incvratio,	".1" }, \
51 -
	{ MODKEY,			XK_h,		inchratio,	".1" }, \
52 -
	{ MODKEY,			XK_l,		incvratio,	"-.1" }, \
53 -
	{ MODKEY,			XK_l,		inchratio,	"-.1" }, \
54 -
	{ MODKEY|ShiftMask,		XK_j,		incnmaster,	"1" }, \
55 -
	{ MODKEY|ShiftMask,		XK_k,		incnmaster,	"-1" }, \
50 +
	{ MODKEY,			XK_h,		incnmaster,	"1" }, \
51 +
	{ MODKEY,			XK_l,		incnmaster,	"-1" }, \
56 52
	{ MODKEY,			XK_j,		focusclient,	"1" }, \
57 53
	{ 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" }, \
58 58
	{ MODKEY,			XK_m,		togglemax,	NULL }, \
59 59
	{ MODKEY,			XK_Return,	zoom,		NULL }, \
60 60
	{ MODKEY|ShiftMask,		XK_space,	togglefloating,	NULL }, \
config.default.h +6 −4
45 45
	{ MODKEY,			XK_p,		spawn, 		"exe=`dmenu_path | dmenu` && exec $exe" }, \
46 46
	{ MODKEY,			XK_space,	setlayout,	NULL }, \
47 47
	{ MODKEY,			XK_b,		togglebar,	NULL }, \
48 -
	{ MODKEY,			XK_h,		incvratio,	".1" }, \
49 -
	{ MODKEY,			XK_l,		incvratio,	"-.1" }, \
50 -
	{ MODKEY|ShiftMask,		XK_j,		incnmaster,	"1" }, \
51 -
	{ MODKEY|ShiftMask,		XK_k,		incnmaster,	"-1" }, \
48 +
	{ MODKEY,			XK_h,		incnmaster,	"1" }, \
49 +
	{ MODKEY,			XK_l,		incnmaster,	"-1" }, \
52 50
	{ MODKEY,			XK_j,		focusclient,	"1" }, \
53 51
	{ 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" }, \
54 56
	{ MODKEY,			XK_m,		togglemax,	NULL }, \
55 57
	{ MODKEY,			XK_Return,	zoom,		NULL }, \
56 58
	{ MODKEY|ShiftMask,		XK_space,	togglefloating,	NULL }, \
dwm.1 +12 −6
68 68
.B Mod1\-k
69 69
Focus previous window.
70 70
.TP
71 -
.B Mod1\-Shift\-j
71 +
.B Mod1\-l
72 72
Increase the number of windows in the master area (tiled layout only).
73 73
.TP
74 -
.B Mod1\-Shift\-k
74 +
.B Mod1\-h
75 75
Decrease the number of windows in the master area (tiled layout only).
76 76
.TP
77 -
.B Mod1\-l
78 -
Increase master area width (tiled layout only).
77 +
.B Mod1\-Shift\-j
78 +
Increase vertical tile ratio, effects tile heights (tiled layout only).
79 79
.TP
80 -
.B Mod1\-h
81 -
Decrease master area width (tiled layout only).
80 +
.B Mod1\-Shift\-k
81 +
Decrease vertical tile ratio, effects tile heights (tiled layout only).
82 +
.TP
83 +
.B Mod1\-Shift\-l
84 +
Increase horizontal tile ratio, effects master area width (tiled layout only).
85 +
.TP
86 +
.B Mod1\-Shift\-h
87 +
Decrease horizontal tile ratio, effects master area width (tiled layout only).
82 88
.TP
83 89
.B Mod1\-m
84 90
Toggles maximization of current window (floating layout only).
layout.c +35 −18
25 25
26 26
static void
27 27
tile(void) {
28 -
	double mscale = 0, tscale = 0, sum = 0;
28 +
	Bool mmaxtile = False, smaxtile = False; /* fallback tiling */
29 +
	double mscale = 0, sscale = 0, sum = 0;
29 30
	unsigned int i, n, nx, ny, nw, nh, mw, tw;
30 31
	Client *c;
31 32
33 +
	/* preparation */
32 34
	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
33 35
		n++;
34 -
36 +
	nx = wax;
37 +
	ny = way;
35 38
	mw = (n <= nmaster) ? waw :  waw / (1 + hratio);
36 39
	tw = waw - mw;
37 -
38 40
	if(n > 0) {
39 -
		if(n < nmaster) {
41 +
		if(n <= nmaster) {
40 42
			for(i = 0; i < n; i++)
41 43
				sum += spow(vratio, i);
42 44
			mscale = wah / sum;
45 +
			if(vratio >= 1)
46 +
				mmaxtile = bh > (mscale * spow(vratio, 0));
47 +
			else
48 +
				mmaxtile = bh > (mscale * spow(vratio, n - 1));
43 49
		}
44 50
		else {
45 51
			for(i = 0; i < nmaster; i++)
47 53
			mscale = wah / sum;
48 54
			for(sum = 0, i = 0; i < (n - nmaster); i++)
49 55
				sum += spow(vratio, i);
50 -
			tscale = wah / sum;
56 +
			sscale = wah / sum;
57 +
			if(vratio >= 1) {
58 +
				mmaxtile = bh > (mscale * spow(vratio, 0));
59 +
				smaxtile = bh > (sscale * spow(vratio, 0));
60 +
			}
61 +
			else {
62 +
				mmaxtile = bh > (mscale * spow(vratio, nmaster - 1));
63 +
				smaxtile = bh > (sscale * spow(vratio, n - nmaster - 1));
64 +
			}
51 65
		}
52 66
	}
53 -
	nx = wax;
54 -
	ny = way;
67 +
	/* tiling */
55 68
	for(i = 0, c = clients; c; c = c->next)
56 69
		if(isvisible(c)) {
57 70
			unban(c);
60 73
			c->ismax = False;
61 74
			if(i < nmaster) { /* master window */
62 75
				nw = mw - 2 * c->border;
63 -
				if(i + 1 == n || i + 1 == nmaster)
64 -
					nh = (way + wah) - ny - (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;
65 82
				else
66 -
					nh = (mscale * spow(vratio, i)) - (2 * c->border);
83 +
					nh = (mscale * spow(vratio, i)) - 2 * c->border;
67 84
			}
68 85
			else { /* tile window */
86 +
				nw = tw - 2 * c->border;
69 87
				if(i == nmaster) {
70 88
					ny = way;
71 89
					nx = wax + mw;
72 90
				}
73 -
				nw = tw - 2 * c->border;
74 -
				if(i + 1 == n)
75 -
					nh = (way + wah) - ny - (2 * c->border);
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;
76 97
				else
77 -
					nh = (tscale * spow(vratio, i - nmaster)) - (2 * c->border);
78 -
			}
79 -
			if(nh < bh) {
80 -
				nh = bh;
81 -
				ny = way + wah - nh;
98 +
					nh = (sscale * spow(vratio, i - nmaster)) - 2 * c->border;
82 99
			}
83 100
			resize(c, nx, ny, nw, nh, False);
84 101
			ny += nh;