X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=view.c;h=3e786613502b16b5822ba68502c82f0759a27cad;hb=0925dd588c6879916c8a9ded1e680963b093b068;hp=b76b47e8103a97d3b1e90dd4b545aaec6fe19de6;hpb=e1315fd40cf7f3df911e1b4f6876c47ce1feb61c;p=dwm.git diff --git a/view.c b/view.c index b76b47e..3e78661 100644 --- a/view.c +++ b/view.c @@ -12,13 +12,14 @@ minclient() { Client *c, *min; + if((clients && clients->isfloat) || arrange == dofloat) + return clients; /* don't touch floating order */ for(min = c = clients; c; c = c->next) if(c->weight < min->weight) min = c; return min; } - static void reorder() { @@ -38,6 +39,13 @@ reorder() clients = newclients; } +static Client * +nexttiled(Client *c) +{ + for(c = getnext(c); c && c->isfloat; c = getnext(c->next)); + return c; +} + /* extern */ void (*arrange)(Arg *) = DEFMODE; @@ -68,8 +76,10 @@ dofloat(Arg *arg) else ban(c); } - if(!sel || !isvisible(sel)) - focus(getnext(clients)); + if(!sel || !isvisible(sel)) { + for(c = stack; c && !isvisible(c); c = c->snext); + focus(c); + } restack(); } @@ -130,8 +140,10 @@ dotile(Arg *arg) else ban(c); } - if(!sel || !isvisible(sel)) - focus(getnext(clients)); + if(!sel || !isvisible(sel)) { + for(c = stack; c && !isvisible(c); c = c->snext); + focus(c); + } restack(); } @@ -208,52 +220,22 @@ resizecol(Arg *arg) void restack() { - static unsigned int nwins = 0; - static Window *wins = NULL; - unsigned int f, fi, m, mi, n; Client *c; XEvent ev; - - for(f = 0, m = 0, c = clients; c; c = c->next) - if(isvisible(c)) { - if(c->isfloat || arrange == dofloat) - f++; - else - m++; - } - if(!(n = 2 * (f + m))) { + + if(!sel) { drawstatus(); return; } - if(nwins < n) { - nwins = n; - wins = erealloc(wins, nwins * sizeof(Window)); + if(sel->isfloat || arrange == dofloat) { + XRaiseWindow(dpy, sel->win); + XRaiseWindow(dpy, sel->twin); } - - fi = 0; - mi = 2 * f; - if(sel) { - if(sel->isfloat || arrange == dofloat) { - wins[fi++] = sel->twin; - wins[fi++] = sel->win; - } - else { - wins[mi++] = sel->twin; - wins[mi++] = sel->win; - } - } - for(c = clients; c; c = c->next) - if(isvisible(c) && c != sel) { - if(c->isfloat || arrange == dofloat) { - wins[fi++] = c->twin; - wins[fi++] = c->win; - } - else { - wins[mi++] = c->twin; - wins[mi++] = c->win; - } + if(arrange != dofloat) + for(c = nexttiled(clients); c; c = nexttiled(c->next)) { + XLowerWindow(dpy, c->twin); + XLowerWindow(dpy, c->win); } - XRestackWindows(dpy, wins, n); drawall(); XSync(dpy, False); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); @@ -317,19 +299,13 @@ zoom(Arg *arg) if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized) return; - /* this is somewhat tricky, it asserts to only zoom tiled clients */ - for(c = clients; c && c->isfloat; c = getnext(c->next)); - if(c) { - if(c == sel) - for(c = getnext(c->next); c && c->isfloat; c = getnext(c->next)); - else - c = sel; - } - if(!c) - return; + if((c = sel) == nexttiled(clients)) + if(!(c = nexttiled(c->next))) + return; detach(c); + if(clients) + clients->prev = c; c->next = clients; - clients->prev = c; clients = c; focus(c); arrange(NULL);