X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=view.c;h=eddf2dadc0baf79da8afe0ff46a244efc3fbebe5;hb=a33150eb4b041b243d0493cd4b53bfbcace3299e;hp=ac201e60e13ba39ceafba9fa52cd68cd860f9793;hpb=0915da8842fd6e16b804ae3205ec2f6baaaa342c;p=dwm.git diff --git a/view.c b/view.c index ac201e6..eddf2da 100644 --- a/view.c +++ b/view.c @@ -18,6 +18,15 @@ minclient() return min; } +static void +pop(Client *c) +{ + detach(c); + if(clients) + clients->prev = c; + c->next = clients; + clients = c; +} static void reorder() @@ -41,7 +50,7 @@ reorder() static Client * nexttiled(Client *c) { - for(c = getnext(c->next); c && c->isfloat; c = getnext(c->next)); + for(c = getnext(c); c && c->isfloat; c = getnext(c->next)); return c; } @@ -215,52 +224,23 @@ 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) { + pop(sel); + 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; + if(arrange != dofloat) + for(c = nexttiled(clients); c; c = nexttiled(c->next)) { + XLowerWindow(dpy, c->twin); + XLowerWindow(dpy, c->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; - } - } - XRestackWindows(dpy, wins, n); drawall(); XSync(dpy, False); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); @@ -325,12 +305,9 @@ zoom(Arg *arg) return; if((c = sel) == nexttiled(clients)) - if(!(c = nexttiled(c))) + if(!(c = nexttiled(c->next))) return; - detach(c); - c->next = clients; - clients->prev = c; - clients = c; + pop(c); focus(c); arrange(NULL); }