tI introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves l… | |
git clone git://src.adamsgaard.dk/dwm | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 4135e34dfa61d32625ef20e8e38064b465402f4a | |
parent 846128a498759bfcbf363fc014e50c1bf48bdf0c | |
Author: Anselm R. Garbe <[email protected]> | |
Date: Sat, 4 Aug 2007 10:51:39 +0200 | |
I introduced {H,V}RATIO and inc{h,v,}ratio() functions - the default behaves li… | |
Diffstat: | |
M config.arg.h | 9 ++++++--- | |
M config.default.h | 7 ++++--- | |
M dwm.h | 4 ++-- | |
M layout.c | 53 +++++++++++++++++++----------… | |
4 files changed, 44 insertions(+), 29 deletions(-) | |
--- | |
diff --git a/config.arg.h b/config.arg.h | |
t@@ -31,7 +31,8 @@ static Layout layout[] = { \ | |
{ "><>", floating }, \ | |
}; | |
#define NMASTER 1 /* clients in master area */ | |
-#define RATIO .8 /* ratio of tile */ | |
+#define HRATIO .8 /* horizontal ratio of tile */ | |
+#define VRATIO .8 /* vertical ratio of tile */ | |
#define SNAP 32 /* snap pixel */ | |
/* key definitions */ | |
t@@ -46,8 +47,10 @@ static Key key[] = { \ | |
"exec urxvtcd -tr -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"F… | |
{ MODKEY, XK_space, setlayout, NU… | |
{ MODKEY, XK_b, togglebar, … | |
- { MODKEY, XK_h, incratio, … | |
- { MODKEY, XK_l, incratio, … | |
+ { MODKEY, XK_h, incvratio, … | |
+ { MODKEY, XK_h, inchratio, … | |
+ { MODKEY, XK_l, incvratio, … | |
+ { MODKEY, XK_l, inchratio, … | |
{ MODKEY|ShiftMask, XK_j, incnmaster, … | |
{ MODKEY|ShiftMask, XK_k, incnmaster, … | |
{ MODKEY, XK_j, focusclient, … | |
diff --git a/config.default.h b/config.default.h | |
t@@ -32,7 +32,8 @@ static Layout layout[] = { \ | |
{ "><>", floating }, \ | |
}; | |
#define NMASTER 1 /* clients in master area */ | |
-#define RATIO .8 /* ratio of tile */ | |
+#define HRATIO .8 /* horizontal ratio of tile */ | |
+#define VRATIO 1 /* vertical ratio of tile */ | |
#define SNAP 32 /* snap pixel */ | |
/* key definitions */ | |
t@@ -44,8 +45,8 @@ static Key key[] = { \ | |
{ MODKEY, XK_p, spawn, … | |
{ MODKEY, XK_space, setlayout, NU… | |
{ MODKEY, XK_b, togglebar, … | |
- { MODKEY, XK_h, incratio, … | |
- { MODKEY, XK_l, incratio, … | |
+ { MODKEY, XK_h, incvratio, … | |
+ { MODKEY, XK_l, incvratio, … | |
{ MODKEY|ShiftMask, XK_j, incnmaster, … | |
{ MODKEY|ShiftMask, XK_k, incnmaster, … | |
{ MODKEY, XK_j, focusclient, … | |
diff --git a/dwm.h b/dwm.h | |
t@@ -44,7 +44,6 @@ enum { WMProtocols, WMDelete, WMState, WMLast }; /* d… | |
typedef struct Client Client; | |
struct Client { | |
char name[256]; | |
- float scale; | |
int x, y, w, h; | |
int rx, ry, rw, rh; /* revert geometry */ | |
int basew, baseh, incw, inch, maxw, maxh, minw, minh; | |
t@@ -123,7 +122,8 @@ void grabkeys(void); /* grab all ke… | |
/* layout.c */ | |
void floating(void); /* arranges all windows floating */ | |
void focusclient(const char *arg); /* focuses next(1)/previous(-1) visi… | |
-void incratio(const char *arg); /* increments the tile ratio wi… | |
+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 */ | |
diff --git a/layout.c b/layout.c | |
t@@ -8,10 +8,29 @@ Layout *lt = NULL; | |
/* static */ | |
-static double ratio = RATIO; | |
+static double hratio = HRATIO; | |
+static double vratio = VRATIO; | |
static unsigned int nlayouts = 0; | |
static unsigned int nmaster = NMASTER; | |
+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(); | |
+} | |
+ | |
static double /* simple pow() */ | |
spow(double x, double y) | |
{ | |
t@@ -31,21 +50,21 @@ tile(void) { | |
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) | |
n++; | |
- mw = (n <= nmaster) ? waw : waw / (1 + ratio); | |
+ mw = (n <= nmaster) ? waw : waw / (1 + hratio); | |
tw = waw - mw; | |
if(n > 0) { | |
if(n < nmaster) { | |
for(i = 0; i < n; i++) | |
- sum += spow(ratio, i); | |
+ sum += spow(vratio, i); | |
mscale = wah / sum; | |
} | |
else { | |
for(i = 0; i < nmaster; i++) | |
- sum += spow(ratio, i); | |
+ sum += spow(vratio, i); | |
mscale = wah / sum; | |
for(sum = 0, i = 0; i < (n - nmaster); i++) | |
- sum += spow(ratio, i); | |
+ sum += spow(vratio, i); | |
tscale = wah / sum; | |
} | |
} | |
t@@ -62,7 +81,7 @@ tile(void) { | |
if(i + 1 == n || i + 1 == nmaster) | |
nh = (way + wah) - ny - (2 * c->border… | |
else | |
- nh = (mscale * spow(ratio, i)) - (2 * … | |
+ nh = (mscale * spow(vratio, i)) - (2 *… | |
} | |
else { /* tile window */ | |
if(i == nmaster) { | |
t@@ -73,7 +92,7 @@ tile(void) { | |
if(i + 1 == n) | |
nh = (way + wah) - ny - (2 * c->border… | |
else | |
- nh = (tscale * spow(ratio, i - nmaster… | |
+ nh = (tscale * spow(vratio, i - nmaste… | |
} | |
if(nh < bh) { | |
nh = bh; | |
t@@ -133,21 +152,13 @@ focusclient(const char *arg) { | |
} | |
void | |
-incratio(const char *arg) { | |
- double delta; | |
+inchratio(const char *arg) { | |
+ incratio(arg, &hratio, HRATIO); | |
+} | |
- if(lt->arrange != tile) | |
- return; | |
- if(!arg) | |
- ratio = RATIO; | |
- else { | |
- if(1 == sscanf(arg, "%lf", &delta)) { | |
- if(delta + ratio < .1 || delta + ratio > 1.9) | |
- return; | |
- ratio += delta; | |
- } | |
- } | |
- lt->arrange(); | |
+void | |
+incvratio(const char *arg) { | |
+ incratio(arg, &vratio, VRATIO); | |
} | |
void |