X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=dwm.c;h=dd39fe10e18d4a5982a3508ba3b307c623d23afe;hb=83abfc05eb5a1e6ee762ce2921d9d5270e40c9ee;hp=e7804dc389796f195c306db8ef96e32acbc3ae36;hpb=9a4d07d9de31c7bf3fba83c66d1a09d63848adfc;p=dwm.git diff --git a/dwm.c b/dwm.c index e7804dc..dd39fe1 100644 --- a/dwm.c +++ b/dwm.c @@ -180,6 +180,7 @@ static void setclientstate(Client *c, long state); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); +static void showhide(Client *c); static void spawn(const Arg *arg); static void tag(const Arg *arg); static int textnw(const char *text, unsigned int len); @@ -271,18 +272,7 @@ applyrules(Client *c) { void arrange(void) { - Client *c; - - for(c = clients; c; c = c->next) - if(ISVISIBLE(c)) { - XMoveWindow(dpy, c->win, c->x, c->y); - if(!lt[sellt]->arrange || c->isfloating) - resize(c, c->x, c->y, c->w, c->h, True); - } - else { - XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); - } - + showhide(stack); focus(NULL); if(lt[sellt]->arrange) lt[sellt]->arrange(); @@ -1377,6 +1367,22 @@ setup(void) { } void +showhide(Client *c) { + if(!c) + return; + if(ISVISIBLE(c)) { /* show clients top down */ + XMoveWindow(dpy, c->win, c->x, c->y); + if(!lt[sellt]->arrange || c->isfloating) + resize(c, c->x, c->y, c->w, c->h, True); + showhide(c->snext); + } + else { /* hide clients bottom up */ + showhide(c->snext); + XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); + } +} + +void spawn(const Arg *arg) { /* The double-fork construct avoids zombie processes and keeps the code * clean from stupid signal handlers. */ @@ -1584,7 +1590,9 @@ updatesizehints(Client *c) { long msize; XSizeHints size; - XGetWMNormalHints(dpy, c->win, &size, &msize); + if(!XGetWMNormalHints(dpy, c->win, &size, &msize)) + /* size is uninitialized, ensure that size.flags aren't used */ + size.flags = PSize; if(size.flags & PBaseSize) { c->basew = size.base_width; c->baseh = size.base_height;