summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@gmail.com>2007-08-05 12:47:52 +0200
committerAnselm R. Garbe <garbeam@gmail.com>2007-08-05 12:47:52 +0200
commit796925089cff58fbea4a1954cf0df57a6a648562 (patch)
tree831fc4a48983210e3c9a7363e1e2ed68757d4528
parentsmall fix of static function order (diff)
downloaddwm-796925089cff58fbea4a1954cf0df57a6a648562.tar.gz
dwm-796925089cff58fbea4a1954cf0df57a6a648562.zip
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)
-rw-r--r--config.arg.h14
-rw-r--r--config.default.h10
-rw-r--r--dwm.118
-rw-r--r--layout.c53
4 files changed, 60 insertions, 35 deletions
diff --git a/config.arg.h b/config.arg.h
index 2a1a784..de3a623 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -32,7 +32,7 @@ static Layout layout[] = { \
32}; 32};
33#define NMASTER 1 /* clients in master area */ 33#define NMASTER 1 /* clients in master area */
34#define HRATIO .8 /* horizontal ratio of tile */ 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#define SNAP 32 /* snap pixel */ 36#define SNAP 32 /* snap pixel */
37 37
38/* key definitions */ 38/* key definitions */
@@ -47,14 +47,14 @@ static Key key[] = { \
47 "exec urxvtcd -tr -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \ 47 "exec urxvtcd -tr -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \
48 { MODKEY, XK_space, setlayout, NULL }, \ 48 { MODKEY, XK_space, setlayout, NULL }, \
49 { MODKEY, XK_b, togglebar, NULL }, \ 49 { MODKEY, XK_b, togglebar, NULL }, \
50 { MODKEY, XK_h, incvratio, ".1" }, \ 50 { MODKEY, XK_h, incnmaster, "1" }, \
51 { MODKEY, XK_h, inchratio, ".1" }, \ 51 { MODKEY, XK_l, incnmaster, "-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" }, \
56 { MODKEY, XK_j, focusclient, "1" }, \ 52 { MODKEY, XK_j, focusclient, "1" }, \
57 { MODKEY, XK_k, focusclient, "-1" }, \ 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 { MODKEY, XK_m, togglemax, NULL }, \ 58 { MODKEY, XK_m, togglemax, NULL }, \
59 { MODKEY, XK_Return, zoom, NULL }, \ 59 { MODKEY, XK_Return, zoom, NULL }, \
60 { MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \ 60 { MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \
diff --git a/config.default.h b/config.default.h
index 9ea02a9..eaba9fb 100644
--- a/config.default.h
+++ b/config.default.h
@@ -45,12 +45,14 @@ static Key key[] = { \
45 { MODKEY, XK_p, spawn, "exe=`dmenu_path | dmenu` && exec $exe" }, \ 45 { MODKEY, XK_p, spawn, "exe=`dmenu_path | dmenu` && exec $exe" }, \
46 { MODKEY, XK_space, setlayout, NULL }, \ 46 { MODKEY, XK_space, setlayout, NULL }, \
47 { MODKEY, XK_b, togglebar, NULL }, \ 47 { MODKEY, XK_b, togglebar, NULL }, \
48 { MODKEY, XK_h, incvratio, ".1" }, \ 48 { MODKEY, XK_h, incnmaster, "1" }, \
49 { MODKEY, XK_l, incvratio, "-.1" }, \ 49 { MODKEY, XK_l, incnmaster, "-1" }, \
50 { MODKEY|ShiftMask, XK_j, incnmaster, "1" }, \
51 { MODKEY|ShiftMask, XK_k, incnmaster, "-1" }, \
52 { MODKEY, XK_j, focusclient, "1" }, \ 50 { MODKEY, XK_j, focusclient, "1" }, \
53 { MODKEY, XK_k, focusclient, "-1" }, \ 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 { MODKEY, XK_m, togglemax, NULL }, \ 56 { MODKEY, XK_m, togglemax, NULL }, \
55 { MODKEY, XK_Return, zoom, NULL }, \ 57 { MODKEY, XK_Return, zoom, NULL }, \
56 { MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \ 58 { MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \
diff --git a/dwm.1 b/dwm.1
index 054f945..b1b04eb 100644
--- a/dwm.1
+++ b/dwm.1
@@ -68,17 +68,23 @@ Focus next window.
68.B Mod1\-k 68.B Mod1\-k
69Focus previous window. 69Focus previous window.
70.TP 70.TP
71.B Mod1\-Shift\-j 71.B Mod1\-l
72Increase the number of windows in the master area (tiled layout only). 72Increase the number of windows in the master area (tiled layout only).
73.TP 73.TP
74.B Mod1\-Shift\-k 74.B Mod1\-h
75Decrease the number of windows in the master area (tiled layout only). 75Decrease the number of windows in the master area (tiled layout only).
76.TP 76.TP
77.B Mod1\-l 77.B Mod1\-Shift\-j
78Increase master area width (tiled layout only). 78Increase vertical tile ratio, effects tile heights (tiled layout only).
79.TP 79.TP
80.B Mod1\-h 80.B Mod1\-Shift\-k
81Decrease master area width (tiled layout only). 81Decrease vertical tile ratio, effects tile heights (tiled layout only).
82.TP
83.B Mod1\-Shift\-l
84Increase horizontal tile ratio, effects master area width (tiled layout only).
85.TP
86.B Mod1\-Shift\-h
87Decrease horizontal tile ratio, effects master area width (tiled layout only).
82.TP 88.TP
83.B Mod1\-m 89.B Mod1\-m
84Toggles maximization of current window (floating layout only). 90Toggles maximization of current window (floating layout only).
diff --git a/layout.c b/layout.c
index b475d35..2016917 100644
--- a/layout.c
+++ b/layout.c
@@ -25,21 +25,27 @@ spow(double x, double y)
25 25
26static void 26static void
27tile(void) { 27tile(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 unsigned int i, n, nx, ny, nw, nh, mw, tw; 30 unsigned int i, n, nx, ny, nw, nh, mw, tw;
30 Client *c; 31 Client *c;
31 32
33 /* preparation */
32 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) 34 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
33 n++; 35 n++;
34 36 nx = wax;
37 ny = way;
35 mw = (n <= nmaster) ? waw : waw / (1 + hratio); 38 mw = (n <= nmaster) ? waw : waw / (1 + hratio);
36 tw = waw - mw; 39 tw = waw - mw;
37
38 if(n > 0) { 40 if(n > 0) {
39 if(n < nmaster) { 41 if(n <= nmaster) {
40 for(i = 0; i < n; i++) 42 for(i = 0; i < n; i++)
41 sum += spow(vratio, i); 43 sum += spow(vratio, i);
42 mscale = wah / sum; 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 else { 50 else {
45 for(i = 0; i < nmaster; i++) 51 for(i = 0; i < nmaster; i++)
@@ -47,11 +53,18 @@ tile(void) {
47 mscale = wah / sum; 53 mscale = wah / sum;
48 for(sum = 0, i = 0; i < (n - nmaster); i++) 54 for(sum = 0, i = 0; i < (n - nmaster); i++)
49 sum += spow(vratio, i); 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; 67 /* tiling */
54 ny = way;
55 for(i = 0, c = clients; c; c = c->next) 68 for(i = 0, c = clients; c; c = c->next)
56 if(isvisible(c)) { 69 if(isvisible(c)) {
57 unban(c); 70 unban(c);
@@ -60,25 +73,29 @@ tile(void) {
60 c->ismax = False; 73 c->ismax = False;
61 if(i < nmaster) { /* master window */ 74 if(i < nmaster) { /* master window */
62 nw = mw - 2 * c->border; 75 nw = mw - 2 * c->border;
63 if(i + 1 == n || i + 1 == nmaster) 76 if(mmaxtile) {
64 nh = (way + wah) - ny - (2 * c->border); 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 else 82 else
66 nh = (mscale * spow(vratio, i)) - (2 * c->border); 83 nh = (mscale * spow(vratio, i)) - 2 * c->border;
67 } 84 }
68 else { /* tile window */ 85 else { /* tile window */
86 nw = tw - 2 * c->border;
69 if(i == nmaster) { 87 if(i == nmaster) {
70 ny = way; 88 ny = way;
71 nx = wax + mw; 89 nx = wax + mw;
72 } 90 }
73 nw = tw - 2 * c->border; 91 if(smaxtile) {
74 if(i + 1 == n) 92 ny = way;
75 nh = (way + wah) - ny - (2 * c->border); 93 nh = wah - 2 * c->border;
94 }
95 else if(i + 1 == n)
96 nh = (way + wah) - ny - 2 * c->border;
76 else 97 else
77 nh = (tscale * spow(vratio, i - nmaster)) - (2 * c->border); 98 nh = (sscale * spow(vratio, i - nmaster)) - 2 * c->border;
78 }
79 if(nh < bh) {
80 nh = bh;
81 ny = way + wah - nh;
82 } 99 }
83 resize(c, nx, ny, nw, nh, False); 100 resize(c, nx, ny, nw, nh, False);
84 ny += nh; 101 ny += nh;