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;
107 unsigned int md = ((stackpos == StackBottom ? sh - bh : sw) * master) / 100;
110 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
113 if(stackpos == StackBottom) {
115 stackh = sh - bh - md;
124 th = stackh / (n - 1);
128 for(i = 0, c = clients; c; c = c->next) {
131 resize(c, True, TopLeft);
137 if(n == 1) { /* only 1 window */
138 c->w = sw - 2 * BORDERPX;
139 c->h = sh - 2 * BORDERPX - bh;
141 else if(i == 0) { /* master window */
142 if(stackpos == StackLeft)
147 c->w = md - 2 * BORDERPX;
148 c->h = sh - bh - 2 * BORDERPX;
151 c->w = sw - 2 * BORDERPX;
152 c->h = md - 2 * BORDERPX;
156 else { /* tile window */
157 if(stackpos == StackRight)
163 c->y = sy + (i - 1) * th + bh;
165 c->h = sh - c->y - 2 * BORDERPX;
168 c->y = sy + md + (i - 1) * th + bh;
170 c->h = sh - c->y - 2 * BORDERPX;
173 c->w = tw - 2 * BORDERPX;
174 c->h = th - 2 * BORDERPX;
176 else { /* fallback if th < bh */
177 if(stackpos == StackBottom)
179 c->w = stackw - 2 * BORDERPX;
180 c->h = stackh - 2 * BORDERPX;
183 resize(c, False, TopLeft);
189 if(!sel || !isvisible(sel)) {
190 for(c = stack; c && !isvisible(c); c = c->snext);
197 focusnext(Arg *arg) {
203 if(!(c = getnext(sel->next)))
204 c = getnext(clients);
212 focusprev(Arg *arg) {
218 if(!(c = getprev(sel->prev))) {
219 for(c = clients; c && c->next; c = c->next);
229 isvisible(Client *c) {
232 for(i = 0; i < ntags; i++)
233 if(c->tags[i] && seltag[i])
239 resizecol(Arg *arg) {
243 for(n = 0, c = clients; c; c = c->next)
244 if(isvisible(c) && !c->isfloat)
246 if(!sel || sel->isfloat || n < 2 || (arrange == dofloat))
249 if(sel == getnext(clients)) {
250 if(master + arg->i > 95 || master + arg->i < 5)
255 if(master - arg->i > 95 || master - arg->i < 5)
271 if(sel->isfloat || arrange == dofloat) {
272 XRaiseWindow(dpy, sel->win);
273 XRaiseWindow(dpy, sel->twin);
275 if(arrange != dofloat) {
277 XLowerWindow(dpy, sel->twin);
278 XLowerWindow(dpy, sel->win);
280 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
283 XLowerWindow(dpy, c->twin);
284 XLowerWindow(dpy, c->win);
289 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
293 togglemode(Arg *arg) {
294 arrange = (arrange == dofloat) ? dotile : dofloat;
302 toggleview(Arg *arg) {
305 seltag[arg->i] = !seltag[arg->i];
306 for(i = 0; i < ntags && !seltag[i]; i++);
308 seltag[arg->i] = True; /* cannot toggle last view */
314 togglestackpos(Arg *arg) {
315 if(arrange == dofloat)
317 if(stackpos == StackBottom)
320 stackpos = StackBottom;
328 for(i = 0; i < ntags; i++)
330 seltag[arg->i] = True;
339 for(i = 0; i < ntags; i++)
355 if(sel->isfloat || (arrange == dofloat)) {
360 for(n = 0, c = clients; c; c = c->next)
361 if(isvisible(c) && !c->isfloat)
363 if(n < 2 || (arrange == dofloat))
366 if((c = sel) == nexttiled(clients))
367 if(!(c = nexttiled(c->next)))