tremoved VRATIO, NMASTER, inc*(), renamed HRATIO into MASTER, see mailinglist f… | |
git clone git://src.adamsgaard.dk/dwm | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit aa53e39ec0eb39949c5c03d56da08204d14d9ff9 | |
parent 4216bf801f6754ca7b8c87c59166620e0a1d0456 | |
Author: Anselm R. Garbe <[email protected]> | |
Date: Fri, 10 Aug 2007 18:16:05 +0200 | |
removed VRATIO, NMASTER, inc*(), renamed HRATIO into MASTER, see mailinglist fo… | |
Diffstat: | |
M client.c | 6 +++--- | |
M config.arg.h | 13 ++++--------- | |
M config.default.h | 13 ++++--------- | |
M dwm.1 | 22 +++++----------------- | |
M dwm.h | 7 ++----- | |
M event.c | 4 ++-- | |
M layout.c | 214 ++++++++++-------------------… | |
M tag.c | 8 ++++---- | |
8 files changed, 90 insertions(+), 197 deletions(-) | |
--- | |
diff --git a/client.c b/client.c | |
t@@ -230,7 +230,7 @@ manage(Window w, XWindowAttributes *wa) { | |
setclientstate(c, IconicState); | |
c->isbanned = True; | |
focus(c); | |
- lt->arrange(); | |
+ lt->arrange(NULL); | |
} | |
void | |
t@@ -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 | |
t@@ -337,7 +337,7 @@ unmanage(Client *c) { | |
XSync(dpy, False); | |
XSetErrorHandler(xerror); | |
XUngrabServer(dpy); | |
- lt->arrange(); | |
+ lt->arrange(NULL); | |
} | |
void | |
diff --git a/config.arg.h b/config.arg.h | |
t@@ -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 */ | |
t@@ -47,14 +46,10 @@ static Key key[] = { \ | |
"exec urxvtcd -tr -bg '#111' -fg '#eee' -cr '#eee' +sb -fn '"F… | |
{ MODKEY, XK_space, setlayout, NU… | |
{ MODKEY, XK_b, togglebar, … | |
- { MODKEY, XK_h, incnmaster, … | |
- { MODKEY, XK_l, incnmaster, … | |
+ { MODKEY, XK_h, tile, … | |
{ MODKEY, XK_j, focusclient, … | |
{ MODKEY, XK_k, focusclient, … | |
- { MODKEY|ShiftMask, XK_h, inchratio, … | |
- { MODKEY|ShiftMask, XK_l, inchratio, … | |
- { MODKEY|ShiftMask, XK_j, incvratio, … | |
- { MODKEY|ShiftMask, XK_k, incvratio, … | |
+ { MODKEY, XK_l, tile, … | |
{ MODKEY, XK_m, togglemax, … | |
{ MODKEY, XK_Return, zoom, … | |
{ MODKEY|ShiftMask, XK_space, togglefloating, … | |
diff --git a/config.default.h b/config.default.h | |
t@@ -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 */ | |
t@@ -45,14 +44,10 @@ static Key key[] = { \ | |
{ MODKEY, XK_p, spawn, … | |
{ MODKEY, XK_space, setlayout, NU… | |
{ MODKEY, XK_b, togglebar, … | |
- { MODKEY, XK_h, incnmaster, … | |
- { MODKEY, XK_l, incnmaster, … | |
+ { MODKEY, XK_h, tile, … | |
{ MODKEY, XK_j, focusclient, … | |
{ MODKEY, XK_k, focusclient, … | |
- { MODKEY|ShiftMask, XK_h, inchratio, … | |
- { MODKEY|ShiftMask, XK_l, inchratio, … | |
- { MODKEY|ShiftMask, XK_j, incvratio, … | |
- { MODKEY|ShiftMask, XK_k, incvratio, … | |
+ { MODKEY, XK_l, tile, … | |
{ MODKEY, XK_m, togglemax, … | |
{ MODKEY, XK_Return, zoom, … | |
{ MODKEY|ShiftMask, XK_space, togglefloating, … | |
diff --git a/dwm.1 b/dwm.1 | |
t@@ -10,7 +10,7 @@ floating layouts. Either layout can be applied dynamically, … | |
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. | |
t@@ -62,29 +62,17 @@ Zooms/cycles current window to/from master area (tiled lay… | |
.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). | |
diff --git a/dwm.h b/dwm.h | |
t@@ -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 */ | |
t@@ -120,11 +120,8 @@ unsigned int textw(const char *text); /* return th… | |
void grabkeys(void); /* grab all keys defined in config… | |
/* layout.c */ | |
-void floating(void); /* arranges all windows floating */ | |
+void floating(const char *arg); /* arranges all windows floatin… | |
void focusclient(const char *arg); /* focuses next(1)/previous(-1) visi… | |
-void inchratio(const char *arg); /* increments the horizontal tile rati… | |
-void incvratio(const char *arg); /* increments the vertical tile ratio … | |
-void incnmaster(const char *arg); /* increments nmaster with arg's inde… | |
void initlayouts(void); /* initialize layout array */ | |
Client *nexttiled(Client *c); /* returns tiled successor of c */ | |
void restack(void); /* restores z layers of all clients… | |
diff --git a/event.c b/event.c | |
t@@ -216,7 +216,7 @@ configurenotify(XEvent *e) { | |
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dp… | |
XResizeWindow(dpy, barwin, sw, bh); | |
updatebarpos(); | |
- lt->arrange(); | |
+ lt->arrange(NULL); | |
} | |
} | |
t@@ -317,7 +317,7 @@ propertynotify(XEvent *e) { | |
case XA_WM_TRANSIENT_FOR: | |
XGetTransientForHint(dpy, c->win, &trans); | |
if(!c->isfloating && (c->isfloating = (getclie… | |
- lt->arrange(); | |
+ lt->arrange(NULL); | |
break; | |
case XA_WM_NORMAL_HINTS: | |
updatesizehints(c); | |
diff --git a/layout.c b/layout.c | |
t@@ -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… | |
- smaxtile = bh > (sscale * spow(vratio, n - nma… | |
- } | |
- } | |
- } | |
- /* 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 * … | |
- } | |
- 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 - nmaste… | |
- } | |
- 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); | |
t@@ -169,35 +57,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; | |
t@@ -261,19 +120,78 @@ 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) | |
bpos = (BARPOS == BarOff) ? BarTop : BARPOS; | |
else | |
bpos = BarOff; | |
updatebarpos(); | |
- lt->arrange(); | |
+ lt->arrange(NULL); | |
} | |
void | |
t@@ -307,5 +225,5 @@ zoom(const char *arg) { | |
detach(c); | |
attach(c); | |
focus(c); | |
- lt->arrange(); | |
+ lt->arrange(NULL); | |
} | |
diff --git a/tag.c b/tag.c | |
t@@ -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 | |
t@@ -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 | |
t@@ -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 | |
t@@ -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); | |
} |