- for(n = 0, c = clients; c; c = c->next)
- if(isvisible(c) && !c->isfloat)
- n++;
- if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized)
+ if(!sel)
+ return;
+ if(sel->isfloat || (arrange == dofloat)) {
+ togglemax(sel);
+ return;
+ }
+ for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+ n++;
+ if(n <= nmaster || (arrange == dofloat))
+ return;
+
+ for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next))
+ i++;
+ if(c == sel && i < nmaster)
+ for(; c && i < nmaster; c = nexttiled(c->next))
+ i++;
+ if(!c)