1
0

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)

This commit is contained in:
Anselm R. Garbe 2007-08-05 12:47:52 +02:00
parent da91dfc948
commit 796925089c
4 changed files with 60 additions and 35 deletions

View File

@ -32,7 +32,7 @@ static Layout layout[] = { \
}; };
#define NMASTER 1 /* clients in master area */ #define NMASTER 1 /* clients in master area */
#define HRATIO .8 /* horizontal ratio of tile */ #define HRATIO .8 /* horizontal ratio of tile */
#define VRATIO .8 /* vertical ratio of tile */ #define VRATIO .9 /* vertical ratio of tile */
#define SNAP 32 /* snap pixel */ #define SNAP 32 /* snap pixel */
/* key definitions */ /* key definitions */
@ -47,14 +47,14 @@ static Key key[] = { \
"exec urxvtcd -tr -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \ "exec urxvtcd -tr -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \
{ MODKEY, XK_space, setlayout, NULL }, \ { MODKEY, XK_space, setlayout, NULL }, \
{ MODKEY, XK_b, togglebar, NULL }, \ { MODKEY, XK_b, togglebar, NULL }, \
{ MODKEY, XK_h, incvratio, ".1" }, \ { MODKEY, XK_h, incnmaster, "1" }, \
{ MODKEY, XK_h, inchratio, ".1" }, \ { MODKEY, XK_l, incnmaster, "-1" }, \
{ MODKEY, XK_l, incvratio, "-.1" }, \
{ MODKEY, XK_l, inchratio, "-.1" }, \
{ MODKEY|ShiftMask, XK_j, incnmaster, "1" }, \
{ MODKEY|ShiftMask, XK_k, incnmaster, "-1" }, \
{ MODKEY, XK_j, focusclient, "1" }, \ { MODKEY, XK_j, focusclient, "1" }, \
{ MODKEY, XK_k, focusclient, "-1" }, \ { MODKEY, XK_k, focusclient, "-1" }, \
{ MODKEY|ShiftMask, XK_h, inchratio, ".1" }, \
{ MODKEY|ShiftMask, XK_l, inchratio, "-.1" }, \
{ MODKEY|ShiftMask, XK_j, incvratio, "-.1" }, \
{ MODKEY|ShiftMask, XK_k, incvratio, ".1" }, \
{ MODKEY, XK_m, togglemax, NULL }, \ { MODKEY, XK_m, togglemax, NULL }, \
{ MODKEY, XK_Return, zoom, NULL }, \ { MODKEY, XK_Return, zoom, NULL }, \
{ MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \ { MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \

View File

@ -45,12 +45,14 @@ static Key key[] = { \
{ MODKEY, XK_p, spawn, "exe=`dmenu_path | dmenu` && exec $exe" }, \ { MODKEY, XK_p, spawn, "exe=`dmenu_path | dmenu` && exec $exe" }, \
{ MODKEY, XK_space, setlayout, NULL }, \ { MODKEY, XK_space, setlayout, NULL }, \
{ MODKEY, XK_b, togglebar, NULL }, \ { MODKEY, XK_b, togglebar, NULL }, \
{ MODKEY, XK_h, incvratio, ".1" }, \ { MODKEY, XK_h, incnmaster, "1" }, \
{ MODKEY, XK_l, incvratio, "-.1" }, \ { MODKEY, XK_l, incnmaster, "-1" }, \
{ MODKEY|ShiftMask, XK_j, incnmaster, "1" }, \
{ MODKEY|ShiftMask, XK_k, incnmaster, "-1" }, \
{ MODKEY, XK_j, focusclient, "1" }, \ { MODKEY, XK_j, focusclient, "1" }, \
{ MODKEY, XK_k, focusclient, "-1" }, \ { MODKEY, XK_k, focusclient, "-1" }, \
{ MODKEY|ShiftMask, XK_h, inchratio, ".1" }, \
{ MODKEY|ShiftMask, XK_l, inchratio, "-.1" }, \
{ MODKEY|ShiftMask, XK_j, incvratio, "-.1" }, \
{ MODKEY|ShiftMask, XK_k, incvratio, ".1" }, \
{ MODKEY, XK_m, togglemax, NULL }, \ { MODKEY, XK_m, togglemax, NULL }, \
{ MODKEY, XK_Return, zoom, NULL }, \ { MODKEY, XK_Return, zoom, NULL }, \
{ MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \ { MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \

18
dwm.1
View File

@ -68,17 +68,23 @@ Focus next window.
.B Mod1\-k .B Mod1\-k
Focus previous window. Focus previous window.
.TP .TP
.B Mod1\-Shift\-j .B Mod1\-l
Increase the number of windows in the master area (tiled layout only). Increase the number of windows in the master area (tiled layout only).
.TP .TP
.B Mod1\-Shift\-k .B Mod1\-h
Decrease the number of windows in the master area (tiled layout only). Decrease the number of windows in the master area (tiled layout only).
.TP .TP
.B Mod1\-l .B Mod1\-Shift\-j
Increase master area width (tiled layout only). Increase vertical tile ratio, effects tile heights (tiled layout only).
.TP .TP
.B Mod1\-h .B Mod1\-Shift\-k
Decrease master area width (tiled layout only). Decrease vertical tile ratio, effects tile heights (tiled layout only).
.TP
.B Mod1\-Shift\-l
Increase horizontal tile ratio, effects master area width (tiled layout only).
.TP
.B Mod1\-Shift\-h
Decrease horizontal tile ratio, effects master area width (tiled layout only).
.TP .TP
.B Mod1\-m .B Mod1\-m
Toggles maximization of current window (floating layout only). Toggles maximization of current window (floating layout only).

View File

@ -25,21 +25,27 @@ spow(double x, double y)
static void static void
tile(void) { tile(void) {
double mscale = 0, tscale = 0, sum = 0; Bool mmaxtile = False, smaxtile = False; /* fallback tiling */
double mscale = 0, sscale = 0, sum = 0;
unsigned int i, n, nx, ny, nw, nh, mw, tw; unsigned int i, n, nx, ny, nw, nh, mw, tw;
Client *c; Client *c;
/* preparation */
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
n++; n++;
nx = wax;
ny = way;
mw = (n <= nmaster) ? waw : waw / (1 + hratio); mw = (n <= nmaster) ? waw : waw / (1 + hratio);
tw = waw - mw; tw = waw - mw;
if(n > 0) { if(n > 0) {
if(n < nmaster) { if(n <= nmaster) {
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
sum += spow(vratio, i); sum += spow(vratio, i);
mscale = wah / sum; mscale = wah / sum;
if(vratio >= 1)
mmaxtile = bh > (mscale * spow(vratio, 0));
else
mmaxtile = bh > (mscale * spow(vratio, n - 1));
} }
else { else {
for(i = 0; i < nmaster; i++) for(i = 0; i < nmaster; i++)
@ -47,11 +53,18 @@ tile(void) {
mscale = wah / sum; mscale = wah / sum;
for(sum = 0, i = 0; i < (n - nmaster); i++) for(sum = 0, i = 0; i < (n - nmaster); i++)
sum += spow(vratio, i); sum += spow(vratio, i);
tscale = wah / sum; sscale = wah / sum;
if(vratio >= 1) {
mmaxtile = bh > (mscale * spow(vratio, 0));
smaxtile = bh > (sscale * spow(vratio, 0));
}
else {
mmaxtile = bh > (mscale * spow(vratio, nmaster - 1));
smaxtile = bh > (sscale * spow(vratio, n - nmaster - 1));
}
} }
} }
nx = wax; /* tiling */
ny = way;
for(i = 0, c = clients; c; c = c->next) for(i = 0, c = clients; c; c = c->next)
if(isvisible(c)) { if(isvisible(c)) {
unban(c); unban(c);
@ -60,25 +73,29 @@ tile(void) {
c->ismax = False; c->ismax = False;
if(i < nmaster) { /* master window */ if(i < nmaster) { /* master window */
nw = mw - 2 * c->border; nw = mw - 2 * c->border;
if(i + 1 == n || i + 1 == nmaster) if(mmaxtile) {
nh = (way + wah) - ny - (2 * c->border); ny = way;
nh = wah - 2 * c->border;
}
else if(i + 1 == (n < nmaster ? n : nmaster))
nh = (way + wah) - ny - 2 * c->border;
else else
nh = (mscale * spow(vratio, i)) - (2 * c->border); nh = (mscale * spow(vratio, i)) - 2 * c->border;
} }
else { /* tile window */ else { /* tile window */
nw = tw - 2 * c->border;
if(i == nmaster) { if(i == nmaster) {
ny = way; ny = way;
nx = wax + mw; nx = wax + mw;
} }
nw = tw - 2 * c->border; if(smaxtile) {
if(i + 1 == n) ny = way;
nh = (way + wah) - ny - (2 * c->border); nh = wah - 2 * c->border;
}
else if(i + 1 == n)
nh = (way + wah) - ny - 2 * c->border;
else else
nh = (tscale * spow(vratio, i - nmaster)) - (2 * c->border); nh = (sscale * spow(vratio, i - nmaster)) - 2 * c->border;
}
if(nh < bh) {
nh = bh;
ny = way + wah - nh;
} }
resize(c, nx, ny, nw, nh, False); resize(c, nx, ny, nw, nh, False);
ny += nh; ny += nh;