2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
13 if((clients && clients->isfloat) || arrange == dofloat)
14 return clients; /* don't touch floating order */
15 for(min = c = clients; c; c = c->next)
16 if(c->weight < min->weight)
22 nexttiled(Client *c) {
23 for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
29 Client *c, *newclients, *tail;
31 newclients = tail = NULL;
32 while((c = minclient())) {
40 tail = newclients = c;
49 if((c->ismax = !c->ismax)) {
50 c->rx = c->x; c->x = sx;
51 c->ry = c->y; c->y = bh;
52 c->rw = c->w; c->w = sw - 2 * BORDERPX;
53 c->rh = c->h; c->h = sh - bh - 2 * BORDERPX;
61 resize(c, True, TopLeft);
62 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
67 void (*arrange)(Arg *) = DEFMODE;
68 StackPos stackpos = STACKPOS;
73 c->prev->next = c->next;
75 c->next->prev = c->prev;
78 c->next = c->prev = NULL;
85 for(c = clients; c; c = c->next) {
87 resize(c, True, TopLeft);
92 if(!sel || !isvisible(sel)) {
93 for(c = stack; c && !isvisible(c); c = c->snext);
99 /* This algorithm is based on a (M)aster area and a (S)tacking area.
100 * It supports following arrangements:
106 unsigned int i, n, md, stackw, stackh, tw, th;
109 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
112 if(stackpos == StackBottom) {
113 md = ((sh - bh) * master) / 100;
115 stackh = sh - bh - md;
118 md = (sw * master) / 100;
125 th = stackh / (n - 1);
129 for(i = 0, c = clients; c; c = c->next) {
132 resize(c, True, TopLeft);
138 if(n == 1) { /* only 1 window */
139 c->w = sw - 2 * BORDERPX;
140 c->h = sh - 2 * BORDERPX - bh;
142 else if(i == 0) { /* master window */
143 if(stackpos == StackLeft)
148 c->w = md - 2 * BORDERPX;
149 c->h = sh - bh - 2 * BORDERPX;
152 c->w = sw - 2 * BORDERPX;
153 c->h = md - 2 * BORDERPX;
157 else { /* tile window */
158 if(stackpos == StackRight)
164 c->y = sy + (i - 1) * th + bh;
166 c->h = sh - c->y - 2 * BORDERPX;
169 c->y = sy + md + (i - 1) * th + bh;
171 c->h = sh - c->y - 2 * BORDERPX;
174 c->w = tw - 2 * BORDERPX;
175 c->h = th - 2 * BORDERPX;
177 else { /* fallback if th < bh */
178 if(stackpos == StackBottom)
180 c->w = stackw - 2 * BORDERPX;
181 c->h = stackh - 2 * BORDERPX;
184 resize(c, False, TopLeft);
190 if(!sel || !isvisible(sel)) {
191 for(c = stack; c && !isvisible(c); c = c->snext);
198 focusnext(Arg *arg) {
204 if(!(c = getnext(sel->next)))
205 c = getnext(clients);
213 focusprev(Arg *arg) {
219 if(!(c = getprev(sel->prev))) {
220 for(c = clients; c && c->next; c = c->next);
230 isvisible(Client *c) {
233 for(i = 0; i < ntags; i++)
234 if(c->tags[i] && seltag[i])
240 resizecol(Arg *arg) {
244 for(n = 0, c = clients; c; c = c->next)
245 if(isvisible(c) && !c->isfloat)
247 if(!sel || sel->isfloat || n < 2 || (arrange == dofloat))
250 if(sel == getnext(clients)) {
251 if(master + arg->i > 95 || master + arg->i < 5)
256 if(master - arg->i > 95 || master - arg->i < 5)
272 if(sel->isfloat || arrange == dofloat) {
273 XRaiseWindow(dpy, sel->win);
274 XRaiseWindow(dpy, sel->twin);
276 if(arrange != dofloat) {
278 XLowerWindow(dpy, sel->twin);
279 XLowerWindow(dpy, sel->win);
281 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
284 XLowerWindow(dpy, c->twin);
285 XLowerWindow(dpy, c->win);
290 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
294 togglemode(Arg *arg) {
295 arrange = (arrange == dofloat) ? dotile : dofloat;
303 toggleview(Arg *arg) {
306 seltag[arg->i] = !seltag[arg->i];
307 for(i = 0; i < ntags && !seltag[i]; i++);
309 seltag[arg->i] = True; /* cannot toggle last view */
315 togglestackpos(Arg *arg) {
316 if(arrange == dofloat)
318 if(stackpos == StackBottom)
321 stackpos = StackBottom;
329 for(i = 0; i < ntags; i++)
331 seltag[arg->i] = True;
340 for(i = 0; i < ntags; i++)
356 if(sel->isfloat || (arrange == dofloat)) {
361 for(n = 0, c = clients; c; c = c->next)
362 if(isvisible(c) && !c->isfloat)
364 if(n < 2 || (arrange == dofloat))
367 if((c = sel) == nexttiled(clients))
368 if(!(c = nexttiled(c->next)))