Mercurial > aewl
comparison view.c @ 505:2c29d74b11dc
first step to a more flexible dotile() algorithm
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Fri, 29 Sep 2006 12:38:27 +0200 |
parents | 0cefc169ff67 |
children | 2824b5d0f0f0 |
comparison
equal
deleted
inserted
replaced
504:0cefc169ff67 | 505:2c29d74b11dc |
---|---|
63 } | 63 } |
64 | 64 |
65 /* extern */ | 65 /* extern */ |
66 | 66 |
67 void (*arrange)(Arg *) = DEFMODE; | 67 void (*arrange)(Arg *) = DEFMODE; |
68 Bool isvertical = VERTICALSTACK; | |
69 StackPos stackpos = STACKPOS; | |
68 | 70 |
69 void | 71 void |
70 detach(Client *c) { | 72 detach(Client *c) { |
71 if(c->prev) | 73 if(c->prev) |
72 c->prev->next = c->next; | 74 c->prev->next = c->next; |
95 restack(); | 97 restack(); |
96 } | 98 } |
97 | 99 |
98 /* This algorithm is based on a (M)aster area and a (S)tacking area. | 100 /* This algorithm is based on a (M)aster area and a (S)tacking area. |
99 * It supports following arrangements: | 101 * It supports following arrangements: |
100 * | 102 * MMMS MMMM SMMM |
101 * MMMS MMMM | 103 * MMMS MMMM SMMM |
102 * MMMS MMMM | 104 * MMMS SSSS SMMM |
103 * MMMS SSSS | |
104 * | |
105 * The stacking area can be set to arrange clients vertically or horizontally. | |
106 * Through inverting the algorithm it can be used to achieve following setup in | |
107 * a dual head environment (due to running two dwm instances concurrently on | |
108 * the specific screen): | |
109 * | |
110 * SMM MMS MMM MMM | |
111 * SMM MMS MMM MMM | |
112 * SMM MMS SSS SSS | |
113 * | |
114 * This uses the center of the two screens for master areas. | |
115 */ | 105 */ |
116 void | 106 void |
117 dotile(Arg *arg) { | 107 dotile(Arg *arg) { |
118 int h, i, n, w; | 108 int h, i, n, w; |
119 Client *c; | 109 Client *c; |
120 | 110 |
121 w = sw - mw; | |
122 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) | 111 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
123 n++; | 112 n++; |
124 | 113 |
125 if(n > 1) | 114 if(isvertical) { |
126 h = (sh - bh) / (n - 1); | 115 if(stackpos == StackBottom) { |
127 else | 116 w = sw; |
128 h = sh - bh; | 117 if(n > 1) |
118 h = (sh - bh) / (n - 1); | |
119 else | |
120 h = sh - bh; | |
121 } | |
122 else { | |
123 w = sw - master; | |
124 if(n > 1) | |
125 h = (sh - bh) / (n - 1); | |
126 else | |
127 h = sh - bh; | |
128 } | |
129 } | |
130 else { /* horizontal stack */ | |
131 | |
132 } | |
129 | 133 |
130 for(i = 0, c = clients; c; c = c->next) { | 134 for(i = 0, c = clients; c; c = c->next) { |
131 if(isvisible(c)) { | 135 if(isvisible(c)) { |
132 if(c->isfloat) { | 136 if(c->isfloat) { |
133 resize(c, True, TopLeft); | 137 resize(c, True, TopLeft); |
141 c->h = sh - 2 * BORDERPX - bh; | 145 c->h = sh - 2 * BORDERPX - bh; |
142 } | 146 } |
143 else if(i == 0) { | 147 else if(i == 0) { |
144 c->x = sx; | 148 c->x = sx; |
145 c->y = sy + bh; | 149 c->y = sy + bh; |
146 c->w = mw - 2 * BORDERPX; | 150 c->w = master - 2 * BORDERPX; |
147 c->h = sh - 2 * BORDERPX - bh; | 151 c->h = sh - 2 * BORDERPX - bh; |
148 } | 152 } |
149 else if(h > bh) { | 153 else if(h > bh) { |
150 c->x = sx + mw; | 154 c->x = sx + master; |
151 c->y = sy + (i - 1) * h + bh; | 155 c->y = sy + (i - 1) * h + bh; |
152 c->w = w - 2 * BORDERPX; | 156 c->w = w - 2 * BORDERPX; |
153 if(i + 1 == n) | 157 if(i + 1 == n) |
154 c->h = sh - c->y - 2 * BORDERPX; | 158 c->h = sh - c->y - 2 * BORDERPX; |
155 else | 159 else |
156 c->h = h - 2 * BORDERPX; | 160 c->h = h - 2 * BORDERPX; |
157 } | 161 } |
158 else { /* fallback if h < bh */ | 162 else { /* fallback if h < bh */ |
159 c->x = sx + mw; | 163 c->x = sx + master; |
160 c->y = sy + bh; | 164 c->y = sy + bh; |
161 c->w = w - 2 * BORDERPX; | 165 c->w = w - 2 * BORDERPX; |
162 c->h = sh - 2 * BORDERPX - bh; | 166 c->h = sh - 2 * BORDERPX - bh; |
163 } | 167 } |
164 resize(c, False, TopLeft); | 168 resize(c, False, TopLeft); |
226 n++; | 230 n++; |
227 if(!sel || sel->isfloat || n < 2 || (arrange == dofloat)) | 231 if(!sel || sel->isfloat || n < 2 || (arrange == dofloat)) |
228 return; | 232 return; |
229 | 233 |
230 if(sel == getnext(clients)) { | 234 if(sel == getnext(clients)) { |
231 if(mw + arg->i > sw - 100 || mw + arg->i < 100) | 235 if(master + arg->i > sw - 100 || master + arg->i < 100) |
232 return; | 236 return; |
233 mw += arg->i; | 237 master += arg->i; |
234 } | 238 } |
235 else { | 239 else { |
236 if(mw - arg->i > sw - 100 || mw - arg->i < 100) | 240 if(master - arg->i > sw - 100 || master - arg->i < 100) |
237 return; | 241 return; |
238 mw -= arg->i; | 242 master -= arg->i; |
239 } | 243 } |
240 arrange(NULL); | 244 arrange(NULL); |
241 } | 245 } |
242 | 246 |
243 void | 247 void |