2wm

dual window manager prototype (minimalist dwm with no tags, just one view)
git clone git://git.suckless.org/2wm
Log | Files | Refs | README | LICENSE

commit ba1e51c7fa8e2ab6ce29d62561e44e38457d293c
parent 23de0f108a1f13652f6451a25e56db26c232afcb
Author: Anselm R. Garbe <arg@suckless.org>
Date:   Mon, 12 Feb 2007 14:25:52 +0100

continued
Diffstat:
2wm.h | 2+-
client.c | 11+++++++----
view.c | 40+++++++++++++++++-----------------------
3 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/2wm.h b/2wm.h @@ -74,7 +74,7 @@ extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ extern void initrregs(void); /* initialize regexps of rules defined in config.h */ extern Client *getnext(Client *c); /* returns next visible client */ extern Client *getprev(Client *c); /* returns previous visible client */ -extern void setvisible(Client *c, Client *trans);/* sets visibility of c */ +extern Bool isfloat(Client *c); /* returns True if c is floatings */ extern void togglevisible(Arg *arg); /* toggles c tags with arg's index */ extern void detach(Client *c); /* detaches c from global client list */ extern void arrange(void); /* arranges all windows tiled */ diff --git a/client.c b/client.c @@ -146,7 +146,7 @@ killclient(Arg *arg) { void manage(Window w, XWindowAttributes *wa) { - Client *c; + Client *c, *t; Window trans; c = emallocz(sizeof(Client)); @@ -178,9 +178,12 @@ manage(Window w, XWindowAttributes *wa) { grabbuttons(c, False); XSetWindowBorder(dpy, c->win, normcol); updatetitle(c); - setvisible(c, getclient(trans)); - if(!c->isfloat) - c->isfloat = trans || c->isfixed; + if((t = getclient(trans))) + c->visible = t->visible; + else + c->visible = visible; + if(!(c->isfloat = isfloat(c))) + c->isfloat = t || c->isfixed; if(clients) clients->prev = c; c->next = clients; diff --git a/view.c b/view.c @@ -83,30 +83,28 @@ initrregs(void) { } } -void -setvisible(Client *c, Client *trans) { +Bool +isfloat(Client *c) { char prop[512]; unsigned int i; regmatch_t tmp; + Bool ret = False; XClassHint ch = { 0 }; - if(trans) - c->visible = trans->visible; - else { - XGetClassHint(dpy, c->win, &ch); - snprintf(prop, sizeof prop, "%s:%s:%s", - ch.res_class ? ch.res_class : "", - ch.res_name ? ch.res_name : "", c->name); - for(i = 0; i < len; i++) - if(rreg[i].regex && !regexec(rreg[i].regex, prop, 1, &tmp, 0)) { - c->isfloat = True; - break; - } - if(ch.res_class) - XFree(ch.res_class); - if(ch.res_name) - XFree(ch.res_name); - } + XGetClassHint(dpy, c->win, &ch); + snprintf(prop, sizeof prop, "%s:%s:%s", + ch.res_class ? ch.res_class : "", + ch.res_name ? ch.res_name : "", c->name); + for(i = 0; i < len; i++) + if(rreg[i].regex && !regexec(rreg[i].regex, prop, 1, &tmp, 0)) { + ret = True; + break; + } + if(ch.res_class) + XFree(ch.res_class); + if(ch.res_name) + XFree(ch.res_name); + return ret; } void @@ -259,10 +257,6 @@ togglefloat(Arg *arg) { void toggleview(Arg *arg) { - Client *c; - - for(c = clients; c; c = c->next) - c->visible = !c->visible; visible = !visible; arrange(); }