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 int i, n, stackw, stackh, tw, th;
109 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
112 if(stackpos == StackBottom) {
114 stackh = sh - bh - master;
117 stackw = sw - master;
123 th = stackh / (n - 1);
127 for(i = 0, c = clients; c; c = c->next) {
130 resize(c, True, TopLeft);
134 if(n == 1) { /* only 1 window */
137 c->w = sw - 2 * BORDERPX;
138 c->h = sh - 2 * BORDERPX - bh;
140 else if(i == 0) { /* master window */
145 c->w = master - 2 * BORDERPX;
146 c->h = sh - bh - 2 * BORDERPX;
151 c->w = sw - 2 * BORDERPX;
152 c->h = master - 2 * BORDERPX;
157 c->w = master - 2 * BORDERPX;
158 c->h = sh - bh - 2 * BORDERPX;
164 c->w = tw - 2 * BORDERPX;
165 c->h = th - 2 * BORDERPX;
169 c->y = sy + (i - 1) * th + bh;
171 c->h = sh - c->y - 2 * BORDERPX;
175 c->y = sy + master + (i - 1) * th + bh;
177 c->h = sh - c->y - 2 * BORDERPX;
181 c->y = sy + (i - 1) * th + bh;
183 c->h = sh - c->y - 2 * BORDERPX;
187 else { /* fallback if th < bh */
188 c->w = stackw - 2 * BORDERPX;
189 c->h = stackh - 2 * BORDERPX;
197 c->y = sy + master + bh;
205 resize(c, False, TopLeft);
211 if(!sel || !isvisible(sel)) {
212 for(c = stack; c && !isvisible(c); c = c->snext);
219 focusnext(Arg *arg) {
225 if(!(c = getnext(sel->next)))
226 c = getnext(clients);
234 focusprev(Arg *arg) {
240 if(!(c = getprev(sel->prev))) {
241 for(c = clients; c && c->next; c = c->next);
251 isvisible(Client *c) {
254 for(i = 0; i < ntags; i++)
255 if(c->tags[i] && seltag[i])
261 resizecol(Arg *arg) {
265 for(n = 0, c = clients; c; c = c->next)
266 if(isvisible(c) && !c->isfloat)
268 if(!sel || sel->isfloat || n < 2 || (arrange == dofloat))
271 if(sel == getnext(clients)) {
272 if(master + arg->i > sw - MINW || master + arg->i < MINW)
277 if(master - arg->i > sw - MINW || master - arg->i < MINW)
293 if(sel->isfloat || arrange == dofloat) {
294 XRaiseWindow(dpy, sel->win);
295 XRaiseWindow(dpy, sel->twin);
297 if(arrange != dofloat) {
299 XLowerWindow(dpy, sel->twin);
300 XLowerWindow(dpy, sel->win);
302 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
305 XLowerWindow(dpy, c->twin);
306 XLowerWindow(dpy, c->win);
311 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
315 togglemode(Arg *arg) {
316 arrange = (arrange == dofloat) ? dotile : dofloat;
324 toggleview(Arg *arg) {
327 seltag[arg->i] = !seltag[arg->i];
328 for(i = 0; i < ntags && !seltag[i]; i++);
330 seltag[arg->i] = True; /* cannot toggle last view */
336 togglestackpos(Arg *arg) {
337 if(arrange == dofloat)
339 if(stackpos == StackBottom)
342 stackpos = StackBottom;
349 master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100;
356 for(i = 0; i < ntags; i++)
358 seltag[arg->i] = True;
367 for(i = 0; i < ntags; i++)
383 if(sel->isfloat || (arrange == dofloat)) {
388 for(n = 0, c = clients; c; c = c->next)
389 if(isvisible(c) && !c->isfloat)
391 if(n < 2 || (arrange == dofloat))
394 if((c = sel) == nexttiled(clients))
395 if(!(c = nexttiled(c->next)))