removed VRATIO, NMASTER, inc*(), renamed HRATIO into MASTER, see mailinglist for details
This commit is contained in:
parent
4216bf801f
commit
aa53e39ec0
6
client.c
6
client.c
@ -230,7 +230,7 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
setclientstate(c, IconicState);
|
||||
c->isbanned = True;
|
||||
focus(c);
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -305,7 +305,7 @@ togglefloating(const char *arg) {
|
||||
sel->isfloating = !sel->isfloating;
|
||||
if(sel->isfloating)
|
||||
resize(sel, sel->x, sel->y, sel->w, sel->h, True);
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -337,7 +337,7 @@ unmanage(Client *c) {
|
||||
XSync(dpy, False);
|
||||
XSetErrorHandler(xerror);
|
||||
XUngrabServer(dpy);
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
13
config.arg.h
13
config.arg.h
@ -24,15 +24,14 @@ static Rule rule[] = { \
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
void tile(const char *arg); /* arranges all windows tiled */
|
||||
#define LAYOUTS \
|
||||
static Layout layout[] = { \
|
||||
/* symbol function */ \
|
||||
{ "[]=", tile }, /* first entry is default */ \
|
||||
{ "><>", floating }, \
|
||||
};
|
||||
#define NMASTER 1 /* clients in master area */
|
||||
#define HRATIO .8 /* horizontal ratio of tile */
|
||||
#define VRATIO .9 /* vertical ratio of tile */
|
||||
#define MASTER 0.6 /* 0.1 .. 0.9 */
|
||||
#define SNAP 32 /* snap pixel */
|
||||
|
||||
/* key definitions */
|
||||
@ -47,14 +46,10 @@ static Key key[] = { \
|
||||
"exec urxvtcd -tr -bg '#111' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \
|
||||
{ MODKEY, XK_space, setlayout, NULL }, \
|
||||
{ MODKEY, XK_b, togglebar, NULL }, \
|
||||
{ MODKEY, XK_h, incnmaster, "1" }, \
|
||||
{ MODKEY, XK_l, incnmaster, "-1" }, \
|
||||
{ MODKEY, XK_h, tile, "-0.05" }, \
|
||||
{ MODKEY, XK_j, 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_l, tile, "0.05" }, \
|
||||
{ MODKEY, XK_m, togglemax, NULL }, \
|
||||
{ MODKEY, XK_Return, zoom, NULL }, \
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \
|
||||
|
@ -25,15 +25,14 @@ static Rule rule[] = { \
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
void tile(const char *arg); /* arranges all windows tiled */
|
||||
#define LAYOUTS \
|
||||
static Layout layout[] = { \
|
||||
/* symbol function */ \
|
||||
{ "[]=", tile }, /* first entry is default */ \
|
||||
{ "><>", floating }, \
|
||||
};
|
||||
#define NMASTER 1 /* clients in master area */
|
||||
#define HRATIO .8 /* horizontal ratio of tile */
|
||||
#define VRATIO 1 /* vertical ratio of tile */
|
||||
#define MASTER 0.6 /* 0.1 .. 0.9 */
|
||||
#define SNAP 32 /* snap pixel */
|
||||
|
||||
/* key definitions */
|
||||
@ -45,14 +44,10 @@ static Key key[] = { \
|
||||
{ MODKEY, XK_p, spawn, "exe=`dmenu_path | dmenu` && exec $exe" }, \
|
||||
{ MODKEY, XK_space, setlayout, NULL }, \
|
||||
{ MODKEY, XK_b, togglebar, NULL }, \
|
||||
{ MODKEY, XK_h, incnmaster, "1" }, \
|
||||
{ MODKEY, XK_l, incnmaster, "-1" }, \
|
||||
{ MODKEY, XK_h, tile, "-0.05" }, \
|
||||
{ MODKEY, XK_j, 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_l, tile, "0.05" }, \
|
||||
{ MODKEY, XK_m, togglemax, NULL }, \
|
||||
{ MODKEY, XK_Return, zoom, NULL }, \
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \
|
||||
|
22
dwm.1
22
dwm.1
@ -10,7 +10,7 @@ floating layouts. Either layout can be applied dynamically, optimizing the
|
||||
environment for the application in use and the task performed.
|
||||
.P
|
||||
In tiled layout windows are managed in a master and stacking area. The master
|
||||
area contains the windows which currently need most attention, whereas the
|
||||
area contains the window which currently needs most attention, whereas the
|
||||
stacking area contains all other windows. In floating layout windows can be
|
||||
resized and moved freely. Dialog windows are always managed floating,
|
||||
regardless of the layout applied.
|
||||
@ -62,29 +62,17 @@ Zooms/cycles current window to/from master area (tiled layout only).
|
||||
.B Mod1\-b
|
||||
Shows/hides the status bar.
|
||||
.TP
|
||||
.B Mod1\-h
|
||||
Decreases the master area width about 5% (tiled layout only).
|
||||
.TP
|
||||
.B Mod1\-j
|
||||
Focus next window.
|
||||
.TP
|
||||
.B Mod1\-k
|
||||
Focus previous window.
|
||||
.TP
|
||||
.B Mod1\-h
|
||||
Increase the number of windows in the master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1\-l
|
||||
Decrease the number of windows in the master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1\-Shift\-k
|
||||
Increase vertical tile ratio, effects tile heights (tiled layout only).
|
||||
.TP
|
||||
.B Mod1\-Shift\-j
|
||||
Decrease vertical tile ratio, effects tile heights (tiled layout only).
|
||||
.TP
|
||||
.B Mod1\-Shift\-h
|
||||
Increase horizontal tile ratio, effects master area width (tiled layout only).
|
||||
.TP
|
||||
.B Mod1\-Shift\-l
|
||||
Decrease horizontal tile ratio, effects master area width (tiled layout only).
|
||||
Increases the master area width about 5% (tiled layout only).
|
||||
.TP
|
||||
.B Mod1\-m
|
||||
Toggles maximization of current window (floating layout only).
|
||||
|
7
dwm.h
7
dwm.h
@ -76,7 +76,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
const char *symbol;
|
||||
void (*arrange)(void);
|
||||
void (*arrange)(const char *);
|
||||
} Layout;
|
||||
|
||||
extern const char *tags[]; /* all tags */
|
||||
@ -120,11 +120,8 @@ unsigned int textw(const char *text); /* return the width of text in px*/
|
||||
void grabkeys(void); /* grab all keys defined in config.h */
|
||||
|
||||
/* layout.c */
|
||||
void floating(void); /* arranges all windows floating */
|
||||
void floating(const char *arg); /* arranges all windows floating */
|
||||
void focusclient(const char *arg); /* focuses next(1)/previous(-1) visible client */
|
||||
void inchratio(const char *arg); /* increments the horizontal tile ratio with arg's value */
|
||||
void incvratio(const char *arg); /* increments the vertical tile ratio with arg's value */
|
||||
void incnmaster(const char *arg); /* increments nmaster with arg's index value */
|
||||
void initlayouts(void); /* initialize layout array */
|
||||
Client *nexttiled(Client *c); /* returns tiled successor of c */
|
||||
void restack(void); /* restores z layers of all clients */
|
||||
|
4
event.c
4
event.c
@ -216,7 +216,7 @@ configurenotify(XEvent *e) {
|
||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||
XResizeWindow(dpy, barwin, sw, bh);
|
||||
updatebarpos();
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ propertynotify(XEvent *e) {
|
||||
case XA_WM_TRANSIENT_FOR:
|
||||
XGetTransientForHint(dpy, c->win, &trans);
|
||||
if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
break;
|
||||
case XA_WM_NORMAL_HINTS:
|
||||
updatesizehints(c);
|
||||
|
214
layout.c
214
layout.c
@ -8,131 +8,19 @@ Layout *lt = NULL;
|
||||
|
||||
/* static */
|
||||
|
||||
static double hratio = HRATIO;
|
||||
static double vratio = VRATIO;
|
||||
static unsigned int nlayouts = 0;
|
||||
static unsigned int nmaster = NMASTER;
|
||||
|
||||
static double /* simple pow() */
|
||||
spow(double x, double y)
|
||||
{
|
||||
if(y == 0)
|
||||
return 1;
|
||||
while(--y)
|
||||
x *= x;
|
||||
return x;
|
||||
}
|
||||
|
||||
static void
|
||||
tile(void) {
|
||||
Bool mmaxtile = False, smaxtile = False; /* fallback tiling */
|
||||
double mscale = 0, sscale = 0, sum = 0;
|
||||
unsigned int i, n, nx, ny, nw, nh, mw, tw;
|
||||
Client *c;
|
||||
|
||||
/* preparation */
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
n++;
|
||||
nx = wax;
|
||||
ny = way;
|
||||
mw = (n <= nmaster) ? waw : waw / (1 + hratio);
|
||||
tw = waw - mw;
|
||||
if(n > 0) {
|
||||
if(n <= nmaster) {
|
||||
for(i = 0; i < n; i++)
|
||||
sum += spow(vratio, i);
|
||||
mscale = wah / sum;
|
||||
if(vratio >= 1)
|
||||
mmaxtile = bh > mscale;
|
||||
else
|
||||
mmaxtile = bh > (mscale * spow(vratio, n - 1));
|
||||
}
|
||||
else {
|
||||
for(i = 0; i < nmaster; i++)
|
||||
sum += spow(vratio, i);
|
||||
mscale = wah / sum;
|
||||
for(sum = 0, i = 0; i < (n - nmaster); i++)
|
||||
sum += spow(vratio, i);
|
||||
sscale = wah / sum;
|
||||
if(vratio >= 1) {
|
||||
mmaxtile = bh > mscale;
|
||||
smaxtile = bh > sscale;
|
||||
}
|
||||
else {
|
||||
mmaxtile = bh > (mscale * spow(vratio, nmaster - 1));
|
||||
smaxtile = bh > (sscale * spow(vratio, n - nmaster - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
/* tiling */
|
||||
for(i = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c)) {
|
||||
unban(c);
|
||||
if(c->isfloating)
|
||||
continue;
|
||||
c->ismax = False;
|
||||
if(i < nmaster) { /* master window */
|
||||
nw = mw - 2 * c->border;
|
||||
if(mmaxtile) {
|
||||
ny = way;
|
||||
nh = wah - 2 * c->border;
|
||||
}
|
||||
else if(i + 1 == (n < nmaster ? n : nmaster))
|
||||
nh = (way + wah) - ny - 2 * c->border;
|
||||
else
|
||||
nh = (mscale * spow(vratio, i)) - 2 * c->border;
|
||||
}
|
||||
else { /* tile window */
|
||||
nw = tw - 2 * c->border;
|
||||
if(i == nmaster) {
|
||||
ny = way;
|
||||
nx = wax + mw;
|
||||
}
|
||||
if(smaxtile) {
|
||||
ny = way;
|
||||
nh = wah - 2 * c->border;
|
||||
}
|
||||
else if(i + 1 == n)
|
||||
nh = (way + wah) - ny - 2 * c->border;
|
||||
else
|
||||
nh = (sscale * spow(vratio, i - nmaster)) - 2 * c->border;
|
||||
}
|
||||
resize(c, nx, ny, nw, nh, False);
|
||||
ny += nh;
|
||||
i++;
|
||||
}
|
||||
else
|
||||
ban(c);
|
||||
focus(NULL);
|
||||
restack();
|
||||
}
|
||||
|
||||
LAYOUTS
|
||||
|
||||
static void
|
||||
incratio(const char *arg, double *ratio, double def) {
|
||||
double delta;
|
||||
|
||||
if(lt->arrange != tile)
|
||||
return;
|
||||
if(!arg)
|
||||
*ratio = def;
|
||||
else {
|
||||
if(1 == sscanf(arg, "%lf", &delta)) {
|
||||
if(delta + (*ratio) < .1 || delta + (*ratio) > 1.9)
|
||||
return;
|
||||
*ratio += delta;
|
||||
}
|
||||
}
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
/* extern */
|
||||
|
||||
void
|
||||
floating(void) {
|
||||
floating(const char *arg) {
|
||||
Client *c;
|
||||
|
||||
if(lt->arrange != floating)
|
||||
return;
|
||||
|
||||
for(c = clients; c; c = c->next)
|
||||
if(isvisible(c)) {
|
||||
unban(c);
|
||||
@ -168,35 +56,6 @@ focusclient(const char *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
inchratio(const char *arg) {
|
||||
incratio(arg, &hratio, HRATIO);
|
||||
}
|
||||
|
||||
void
|
||||
incvratio(const char *arg) {
|
||||
incratio(arg, &vratio, VRATIO);
|
||||
}
|
||||
|
||||
void
|
||||
incnmaster(const char *arg) {
|
||||
int i;
|
||||
|
||||
if(!arg)
|
||||
nmaster = NMASTER;
|
||||
else {
|
||||
i = atoi(arg);
|
||||
if((lt->arrange != tile) || (nmaster + i < 1)
|
||||
|| (wah / (nmaster + i) <= 2 * BORDERPX))
|
||||
return;
|
||||
nmaster += i;
|
||||
}
|
||||
if(sel)
|
||||
lt->arrange();
|
||||
else
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
void
|
||||
initlayouts(void) {
|
||||
unsigned int i, w;
|
||||
@ -261,11 +120,70 @@ setlayout(const char *arg) {
|
||||
lt = &layout[i];
|
||||
}
|
||||
if(sel)
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
else
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
void
|
||||
tile(const char *arg) {
|
||||
static double master = MASTER;
|
||||
double delta;
|
||||
unsigned int i, n, nx, ny, nw, nh, mw, th;
|
||||
Client *c;
|
||||
|
||||
if(lt->arrange != tile)
|
||||
return;
|
||||
|
||||
/* arg handling, manipulate master */
|
||||
if(arg && (1 == sscanf(arg, "%lf", &delta))) {
|
||||
if(delta + master > 0.1 && delta + master < 0.9)
|
||||
master += delta;
|
||||
}
|
||||
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
n++;
|
||||
|
||||
/* window geoms */
|
||||
mw = (n == 1) ? waw : master * waw;
|
||||
th = (n > 1) ? wah / (n - 1) : 0;
|
||||
if(n > 1 && th < bh)
|
||||
th = wah;
|
||||
|
||||
nx = wax;
|
||||
ny = way;
|
||||
for(i = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c)) {
|
||||
unban(c);
|
||||
if(c->isfloating)
|
||||
continue;
|
||||
c->ismax = False;
|
||||
if(i == 0) { /* master */
|
||||
nw = mw - 2 * c->border;
|
||||
nh = wah - 2 * c->border;
|
||||
}
|
||||
else { /* tile window */
|
||||
if(i == 1) {
|
||||
ny = way;
|
||||
nx += mw;
|
||||
}
|
||||
nw = waw - mw - 2 * c->border;
|
||||
if(i + 1 == n) /* remainder */
|
||||
nh = (way + wah) - ny - 2 * c->border;
|
||||
else
|
||||
nh = th - 2 * c->border;
|
||||
}
|
||||
resize(c, nx, ny, nw, nh, False);
|
||||
if(n > 1 && th != wah)
|
||||
ny += nh;
|
||||
i++;
|
||||
}
|
||||
else
|
||||
ban(c);
|
||||
focus(NULL);
|
||||
restack();
|
||||
}
|
||||
|
||||
void
|
||||
togglebar(const char *arg) {
|
||||
if(bpos == BarOff)
|
||||
@ -273,7 +191,7 @@ togglebar(const char *arg) {
|
||||
else
|
||||
bpos = BarOff;
|
||||
updatebarpos();
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -307,5 +225,5 @@ zoom(const char *arg) {
|
||||
detach(c);
|
||||
attach(c);
|
||||
focus(c);
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
}
|
||||
|
8
tag.c
8
tag.c
@ -110,7 +110,7 @@ tag(const char *arg) {
|
||||
i = arg ? atoi(arg) : 0;
|
||||
if(i >= 0 && i < ntags)
|
||||
sel->tags[i] = True;
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -124,7 +124,7 @@ toggletag(const char *arg) {
|
||||
for(j = 0; j < ntags && !sel->tags[j]; j++);
|
||||
if(j == ntags)
|
||||
sel->tags[i] = True;
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -136,7 +136,7 @@ toggleview(const char *arg) {
|
||||
for(j = 0; j < ntags && !seltag[j]; j++);
|
||||
if(j == ntags)
|
||||
seltag[i] = True; /* cannot toggle last view */
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -148,5 +148,5 @@ view(const char *arg) {
|
||||
i = arg ? atoi(arg) : 0;
|
||||
if(i >= 0 && i < ntags)
|
||||
seltag[i] = True;
|
||||
lt->arrange();
|
||||
lt->arrange(NULL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user