diff options
Diffstat (limited to 'layout.c')
| -rw-r--r-- | layout.c | 53 |
1 files changed, 32 insertions, 21 deletions
| @@ -8,10 +8,29 @@ Layout *lt = NULL; | |||
| 8 | 8 | ||
| 9 | /* static */ | 9 | /* static */ |
| 10 | 10 | ||
| 11 | static double ratio = RATIO; | 11 | static double hratio = HRATIO; |
| 12 | static double vratio = VRATIO; | ||
| 12 | static unsigned int nlayouts = 0; | 13 | static unsigned int nlayouts = 0; |
| 13 | static unsigned int nmaster = NMASTER; | 14 | static unsigned int nmaster = NMASTER; |
| 14 | 15 | ||
| 16 | static void | ||
| 17 | incratio(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 | |||
| 15 | static double /* simple pow() */ | 34 | static double /* simple pow() */ |
| 16 | spow(double x, double y) | 35 | spow(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 | ||
| 135 | void | 154 | void |
| 136 | incratio(const char *arg) { | 155 | inchratio(const char *arg) { |
| 137 | double delta; | 156 | incratio(arg, &hratio, HRATIO); |
| 157 | } | ||
| 138 | 158 | ||
| 139 | if(lt->arrange != tile) | 159 | void |
| 140 | return; | 160 | incvratio(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 | ||
| 153 | void | 164 | void |
