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 7315d432b1b2ce19e187ecd1a7098a9df2241eb8
parent 11ef0099880202ed0abca5bd3c6477de3329408d
Author: Anselm R. Garbe <arg@suckless.org>
Date:   Mon, 12 Feb 2007 13:18:41 +0100

simplified the rule stuff
Diffstat:
config.default.h | 10++--------
tag.c | 34++++++++++------------------------
2 files changed, 12 insertions(+), 32 deletions(-)

diff --git a/config.default.h b/config.default.h @@ -33,11 +33,5 @@ static Key key[] = { \ { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ }; -#define RULES \ -static Rule rule[] = { \ - /* class:instance:title regex tags regex isfloat */ \ - { "Firefox.*", "3", False }, \ - { "Gimp.*", NULL, True }, \ - { "MPlayer.*", NULL, True }, \ - { "Acroread.*", NULL, True }, \ -}; +#define FLOATS \ +static char *floats[] = { "Gimp.*", "MPlayer.*", "Acroread.*", NULL }; diff --git a/tag.c b/tag.c @@ -10,20 +10,11 @@ #include <X11/Xutil.h> -typedef struct { - const char *clpattern; - const char *tpattern; - Bool isfloat; -} Rule; - -typedef struct { - regex_t *clregex; - regex_t *tregex; -} RReg; +typedef struct { regex_t *regex; } RReg; /* static */ -RULES +FLOATS static RReg *rreg = NULL; static unsigned int len = 0; @@ -49,22 +40,15 @@ initrregs(void) { if(rreg) return; - len = sizeof rule / sizeof rule[0]; + for(len = 0; floats[len]; len++); rreg = emallocz(len * sizeof(RReg)); for(i = 0; i < len; i++) { - if(rule[i].clpattern) { - reg = emallocz(sizeof(regex_t)); - if(regcomp(reg, rule[i].clpattern, REG_EXTENDED)) - free(reg); - else - rreg[i].clregex = reg; - } - if(rule[i].tpattern) { + if(floats[i]) { reg = emallocz(sizeof(regex_t)); - if(regcomp(reg, rule[i].tpattern, REG_EXTENDED)) + if(regcomp(reg, floats[i], REG_EXTENDED)) free(reg); else - rreg[i].tregex = reg; + rreg[i].regex = reg; } } } @@ -84,8 +68,10 @@ setvisible(Client *c, Client *trans) { ch.res_class ? ch.res_class : "", ch.res_name ? ch.res_name : "", c->name); for(i = 0; i < len; i++) - if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) - c->isfloat = rule[i].isfloat; + 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)