wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 5e753ad1ce20b6d666cbe6ce28ba08cec84e3f27
parent e66b83eab29d56f9e32a46f3578bf8aef2b8a69d
Author: Kris Maglione <kris@suckless.org>
Date:   Fri, 22 Jan 2010 20:56:00 -0500

Prefer tag rules to window groups. Closes issue #165.

Update issue #165
You can work around this by adding something like the following to
your /tagrules:

 /terminal/ -> sel # Ignore terminal window groups.

Diffstat:
cmd/wmii/client.c | 50+++++++++++++++++++++++++++-----------------------
cmd/wmii/fns.h | 3+--
cmd/wmii/fs.c | 2+-
cmd/wmii/view.c | 4++--
4 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c @@ -196,11 +196,23 @@ client_create(XWindow w, XWindowAttributes *wa) { return c; } +static bool +apply_rules(Client *c) { + Rule *r; + + if(def.tagrules.string) + for(r=def.tagrules.rule; r; r=r->next) + if(regexec(r->regex, c->props, nil, 0)) + return client_applytags(c, r->value); + return false; +} + void client_manage(Client *c) { Client *leader; Frame *f; char *tags; + bool rules; if(Dx(c->r) == Dx(screen->r)) if(Dy(c->r) == Dy(screen->r)) @@ -208,23 +220,22 @@ client_manage(Client *c) { fullscreen(c, true, -1); tags = getprop_string(&c->w, "_WMII_TAGS"); + rules = apply_rules(c); leader = win2client(c->trans); if(leader == nil && c->group) leader = group_leader(c->group); - if(tags && (!leader || leader == c || starting)) + if(tags) // && (!leader || leader == c || starting)) utflcpy(c->tags, tags, sizeof c->tags); - else if(leader) + else if(leader && !rules) utflcpy(c->tags, leader->tags, sizeof c->tags); free(tags); - if(!c->tags[0]) - apply_rules(c); if(c->tags[0]) - apply_tags(c, c->tags); + client_applytags(c, c->tags); else - apply_tags(c, "sel"); + client_applytags(c, "sel"); if(!starting) view_update_all(); @@ -1052,10 +1063,10 @@ client_extratags(Client *c) { return s; } -void -apply_tags(Client *c, const char *tags) { +bool +client_applytags(Client *c, const char *tags) { uint i, j, k, n; - bool add; + bool add, found; char buf[512], last; char *toks[32]; char **p; @@ -1084,6 +1095,8 @@ apply_tags(Client *c, const char *tags) { add = false; } + found = false; + j = 0; while(buf[n] && n < sizeof(buf) && j < 32) { /* Check for regex. */ @@ -1103,6 +1116,7 @@ apply_tags(Client *c, const char *tags) { last = buf[i]; buf[i] = '\0'; + found = true; goto next; } } @@ -1129,9 +1143,10 @@ apply_tags(Client *c, const char *tags) { cur = buf+n; if(cur && j < nelem(toks)-1) { - if(add) + if(add) { + found = true; toks[j++] = cur; - else { + }else { for(i = 0, k = 0; i < j; i++) if(strcmp(toks[i], cur)) toks[k++] = toks[i]; @@ -1177,17 +1192,6 @@ apply_tags(Client *c, const char *tags) { p = comm(~0, c->retags, toks); client_setviews(c, p); free(p); -} - -void -apply_rules(Client *c) { - Rule *r; - - if(def.tagrules.string) - for(r=def.tagrules.rule; r; r=r->next) - if(regexec(r->regex, c->props, nil, 0)) { - apply_tags(c, r->value); - break; - } + return found; } diff --git a/cmd/wmii/fns.h b/cmd/wmii/fns.h @@ -68,8 +68,7 @@ void bar_setbounds(WMScreen*, int, int); /* client.c */ int Cfmt(Fmt *f); -void apply_rules(Client*); -void apply_tags(Client*, const char*); +bool client_applytags(Client*, const char*); void client_configure(Client*); Client* client_create(XWindow, XWindowAttributes*); void client_destroy(Client*); diff --git a/cmd/wmii/fs.c b/cmd/wmii/fs.c @@ -535,7 +535,7 @@ fs_write(Ixp9Req *r) { return; case FsFCtags: ixp_srv_data2cstring(r); - apply_tags(f->p.client, r->ifcall.io.data); + client_applytags(f->p.client, r->ifcall.io.data); r->ofcall.io.count = r->ifcall.io.count; respond(r, nil); return; diff --git a/cmd/wmii/view.c b/cmd/wmii/view.c @@ -96,7 +96,7 @@ view_create(const char *name) { /* FIXME: Can do better. */ for(c=client; c; c=c->next) if(c != kludge) - apply_tags(c, c->tags); + client_applytags(c, c->tags); view_arrange(v); if(!selview) @@ -132,7 +132,7 @@ view_destroy(View *v) { /* Detach frames held here by regex tags. */ /* FIXME: Can do better. */ foreach_frame(v, s, a, f) - apply_tags(f->client, f->client->tags); + client_applytags(f->client, f->client->tags); foreach_area(v, s, a) area_destroy(a);