summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--config.arg.h9
-rw-r--r--config.default.h7
-rw-r--r--dwm.h4
-rw-r--r--layout.c53
4 files changed, 44 insertions, 29 deletions
diff --git a/config.arg.h b/config.arg.h
index 2720ce3..2a1a784 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -31,7 +31,8 @@ static Layout layout[] = { \
31 { "><>", floating }, \ 31 { "><>", floating }, \
32}; 32};
33#define NMASTER 1 /* clients in master area */ 33#define NMASTER 1 /* clients in master area */
34#define RATIO .8 /* ratio of tile */ 34#define HRATIO .8 /* horizontal ratio of tile */
35#define VRATIO .8 /* vertical ratio of tile */
35#define SNAP 32 /* snap pixel */ 36#define SNAP 32 /* snap pixel */
36 37
37/* key definitions */ 38/* key definitions */
@@ -46,8 +47,10 @@ static Key key[] = { \
46 "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"'" }, \
47 { MODKEY, XK_space, setlayout, NULL }, \ 48 { MODKEY, XK_space, setlayout, NULL }, \
48 { MODKEY, XK_b, togglebar, NULL }, \ 49 { MODKEY, XK_b, togglebar, NULL }, \
49 { MODKEY, XK_h, incratio, ".1" }, \ 50 { MODKEY, XK_h, incvratio, ".1" }, \
50 { MODKEY, XK_l, incratio, "-.1" }, \ 51 { MODKEY, XK_h, inchratio, ".1" }, \
52 { MODKEY, XK_l, incvratio, "-.1" }, \
53 { MODKEY, XK_l, inchratio, "-.1" }, \
51 { MODKEY|ShiftMask, XK_j, incnmaster, "1" }, \ 54 { MODKEY|ShiftMask, XK_j, incnmaster, "1" }, \
52 { MODKEY|ShiftMask, XK_k, incnmaster, "-1" }, \ 55 { MODKEY|ShiftMask, XK_k, incnmaster, "-1" }, \
53 { MODKEY, XK_j, focusclient, "1" }, \ 56 { MODKEY, XK_j, focusclient, "1" }, \
diff --git a/config.default.h b/config.default.h
index 5a8d594..9ea02a9 100644
--- a/config.default.h
+++ b/config.default.h
@@ -32,7 +32,8 @@ static Layout layout[] = { \
32 { "><>", floating }, \ 32 { "><>", floating }, \
33}; 33};
34#define NMASTER 1 /* clients in master area */ 34#define NMASTER 1 /* clients in master area */
35#define RATIO .8 /* ratio of tile */ 35#define HRATIO .8 /* horizontal ratio of tile */
36#define VRATIO 1 /* vertical ratio of tile */
36#define SNAP 32 /* snap pixel */ 37#define SNAP 32 /* snap pixel */
37 38
38/* key definitions */ 39/* key definitions */
@@ -44,8 +45,8 @@ static Key key[] = { \
44 { MODKEY, XK_p, spawn, "exe=`dmenu_path | dmenu` && exec $exe" }, \ 45 { MODKEY, XK_p, spawn, "exe=`dmenu_path | dmenu` && exec $exe" }, \
45 { MODKEY, XK_space, setlayout, NULL }, \ 46 { MODKEY, XK_space, setlayout, NULL }, \
46 { MODKEY, XK_b, togglebar, NULL }, \ 47 { MODKEY, XK_b, togglebar, NULL }, \
47 { MODKEY, XK_h, incratio, ".1" }, \ 48 { MODKEY, XK_h, incvratio, ".1" }, \
48 { MODKEY, XK_l, incratio, "-.1" }, \ 49 { MODKEY, XK_l, incvratio, "-.1" }, \
49 { MODKEY|ShiftMask, XK_j, incnmaster, "1" }, \ 50 { MODKEY|ShiftMask, XK_j, incnmaster, "1" }, \
50 { MODKEY|ShiftMask, XK_k, incnmaster, "-1" }, \ 51 { MODKEY|ShiftMask, XK_k, incnmaster, "-1" }, \
51 { MODKEY, XK_j, focusclient, "1" }, \ 52 { MODKEY, XK_j, focusclient, "1" }, \
diff --git a/dwm.h b/dwm.h
index b5653b1..7f7d422 100644
--- a/dwm.h
+++ b/dwm.h
@@ -44,7 +44,6 @@ enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
44typedef struct Client Client; 44typedef struct Client Client;
45struct Client { 45struct Client {
46 char name[256]; 46 char name[256];
47 float scale;
48 int x, y, w, h; 47 int x, y, w, h;
49 int rx, ry, rw, rh; /* revert geometry */ 48 int rx, ry, rw, rh; /* revert geometry */
50 int basew, baseh, incw, inch, maxw, maxh, minw, minh; 49 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
@@ -123,7 +122,8 @@ void grabkeys(void); /* grab all keys defined in config.h */
123/* layout.c */ 122/* layout.c */
124void floating(void); /* arranges all windows floating */ 123void floating(void); /* arranges all windows floating */
125void focusclient(const char *arg); /* focuses next(1)/previous(-1) visible client */ 124void focusclient(const char *arg); /* focuses next(1)/previous(-1) visible client */
126void incratio(const char *arg); /* increments the tile ratio with arg's value */ 125void inchratio(const char *arg); /* increments the horizontal tile ratio with arg's value */
126void incvratio(const char *arg); /* increments the vertical tile ratio with arg's value */
127void incnmaster(const char *arg); /* increments nmaster with arg's index value */ 127void incnmaster(const char *arg); /* increments nmaster with arg's index value */
128void initlayouts(void); /* initialize layout array */ 128void initlayouts(void); /* initialize layout array */
129Client *nexttiled(Client *c); /* returns tiled successor of c */ 129Client *nexttiled(Client *c); /* returns tiled successor of c */
diff --git a/layout.c b/layout.c
index 5bd0d57..fa7b4eb 100644
--- a/layout.c
+++ b/layout.c
@@ -8,10 +8,29 @@ Layout *lt = NULL;
8 8
9/* static */ 9/* static */
10 10
11static double ratio = RATIO; 11static double hratio = HRATIO;
12static double vratio = VRATIO;
12static unsigned int nlayouts = 0; 13static unsigned int nlayouts = 0;
13static unsigned int nmaster = NMASTER; 14static unsigned int nmaster = NMASTER;
14 15
16static void
17incratio(const char *arg, double *ratio, double def) {
18 double delta;
19
20 if(lt->arrange != tile)
21 return;
22 if(!arg)
23 *ratio = def;
24 else {
25 if(1 == sscanf(arg, "%lf", &delta)) {
26 if(delta + (*ratio) < .1 || delta + (*ratio) > 1.9)
27 return;
28 *ratio += delta;
29 }
30 }
31 lt->arrange();
32}
33
15static double /* simple pow() */ 34static double /* simple pow() */
16spow(double x, double y) 35spow(double x, double y)
17{ 36{
@@ -31,21 +50,21 @@ tile(void) {
31 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) 50 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
32 n++; 51 n++;
33 52
34 mw = (n <= nmaster) ? waw : waw / (1 + ratio); 53 mw = (n <= nmaster) ? waw : waw / (1 + hratio);
35 tw = waw - mw; 54 tw = waw - mw;
36 55
37 if(n > 0) { 56 if(n > 0) {
38 if(n < nmaster) { 57 if(n < nmaster) {
39 for(i = 0; i < n; i++) 58 for(i = 0; i < n; i++)
40 sum += spow(ratio, i); 59 sum += spow(vratio, i);
41 mscale = wah / sum; 60 mscale = wah / sum;
42 } 61 }
43 else { 62 else {
44 for(i = 0; i < nmaster; i++) 63 for(i = 0; i < nmaster; i++)
45 sum += spow(ratio, i); 64 sum += spow(vratio, i);
46 mscale = wah / sum; 65 mscale = wah / sum;
47 for(sum = 0, i = 0; i < (n - nmaster); i++) 66 for(sum = 0, i = 0; i < (n - nmaster); i++)
48 sum += spow(ratio, i); 67 sum += spow(vratio, i);
49 tscale = wah / sum; 68 tscale = wah / sum;
50 } 69 }
51 } 70 }
@@ -62,7 +81,7 @@ tile(void) {
62 if(i + 1 == n || i + 1 == nmaster) 81 if(i + 1 == n || i + 1 == nmaster)
63 nh = (way + wah) - ny - (2 * c->border); 82 nh = (way + wah) - ny - (2 * c->border);
64 else 83 else
65 nh = (mscale * spow(ratio, i)) - (2 * c->border); 84 nh = (mscale * spow(vratio, i)) - (2 * c->border);
66 } 85 }
67 else { /* tile window */ 86 else { /* tile window */
68 if(i == nmaster) { 87 if(i == nmaster) {
@@ -73,7 +92,7 @@ tile(void) {
73 if(i + 1 == n) 92 if(i + 1 == n)
74 nh = (way + wah) - ny - (2 * c->border); 93 nh = (way + wah) - ny - (2 * c->border);
75 else 94 else
76 nh = (tscale * spow(ratio, i - nmaster)) - (2 * c->border); 95 nh = (tscale * spow(vratio, i - nmaster)) - (2 * c->border);
77 } 96 }
78 if(nh < bh) { 97 if(nh < bh) {
79 nh = bh; 98 nh = bh;
@@ -133,21 +152,13 @@ focusclient(const char *arg) {
133} 152}
134 153
135void 154void
136incratio(const char *arg) { 155inchratio(const char *arg) {
137 double delta; 156 incratio(arg, &hratio, HRATIO);
157}
138 158
139 if(lt->arrange != tile) 159void
140 return; 160incvratio(const char *arg) {
141 if(!arg) 161 incratio(arg, &vratio, VRATIO);
142 ratio = RATIO;
143 else {
144 if(1 == sscanf(arg, "%lf", &delta)) {
145 if(delta + ratio < .1 || delta + ratio > 1.9)
146 return;
147 ratio += delta;
148 }
149 }
150 lt->arrange();
151} 162}
152 163
153void 164void