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)
23 Client *c, *newclients, *tail;
25 newclients = tail = NULL;
26 while((c = minclient())) {
34 tail = newclients = c;
40 nexttiled(Client *c) {
41 for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
47 void (*arrange)(Arg *) = DEFMODE;
52 c->prev->next = c->next;
54 c->next->prev = c->prev;
57 c->next = c->prev = NULL;
64 for(c = clients; c; c = c->next) {
66 resize(c, True, TopLeft);
71 if(!sel || !isvisible(sel)) {
72 for(c = stack; c && !isvisible(c); c = c->snext);
84 for(n = 0, c = clients; c; c = c->next)
85 if(isvisible(c) && !c->isfloat)
89 h = (sh - bh) / (n - 1);
93 for(i = 0, c = clients; c; c = c->next) {
96 resize(c, True, TopLeft);
113 c->y = sy + (i - 1) * h + bh;
116 c->h = sh - c->y - 2;
120 else { /* fallback if h < bh */
126 resize(c, False, TopLeft);
132 if(!sel || !isvisible(sel)) {
133 for(c = stack; c && !isvisible(c); c = c->snext);
140 focusnext(Arg *arg) {
146 if(!(c = getnext(sel->next)))
147 c = getnext(clients);
155 focusprev(Arg *arg) {
161 if(!(c = getprev(sel->prev))) {
162 for(c = clients; c && c->next; c = c->next);
172 isvisible(Client *c) {
175 for(i = 0; i < ntags; i++)
176 if(c->tags[i] && seltag[i])
182 resizecol(Arg *arg) {
186 for(n = 0, c = clients; c; c = c->next)
187 if(isvisible(c) && !c->isfloat)
189 if(!sel || sel->isfloat || n < 2 || (arrange != dotile))
192 if(sel == getnext(clients)) {
193 if(mw + arg->i > sw - 100 || mw + arg->i < 100)
198 if(mw - arg->i > sw - 100 || mw - arg->i < 100)
214 if(sel->isfloat || arrange == dofloat) {
215 XRaiseWindow(dpy, sel->win);
216 XRaiseWindow(dpy, sel->twin);
218 if(arrange != dofloat)
219 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
220 XLowerWindow(dpy, c->twin);
221 XLowerWindow(dpy, c->win);
225 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
229 togglemode(Arg *arg) {
230 arrange = (arrange == dofloat) ? dotile : dofloat;
238 toggleview(Arg *arg) {
241 seltag[arg->i] = !seltag[arg->i];
242 for(i = 0; i < ntags && !seltag[i]; i++);
244 seltag[arg->i] = True; /* cannot toggle last view */
253 for(i = 0; i < ntags; i++)
255 seltag[arg->i] = True;
264 for(i = 0; i < ntags; i++)
280 if(sel->isfloat || (arrange == dofloat)) {
281 tmp = sel->x; sel->x = sel->rx; sel->rx = tmp;
282 tmp = sel->y; sel->y = sel->ry; sel->ry = tmp;
283 tmp = sel->w; sel->w = sel->rw; sel->rw = tmp;
284 tmp = sel->h; sel->h = sel->rh; sel->rh = tmp;
285 resize(sel, True, TopLeft);
286 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
290 for(n = 0, c = clients; c; c = c->next)
291 if(isvisible(c) && !c->isfloat)
293 if(n < 2 || (arrange != dotile))
296 if((c = sel) == nexttiled(clients))
297 if(!(c = nexttiled(c->next)))