[hackers] [wmii] Prefer tag rules to window groups. Closes issue #165. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Sat, 23 Jan 2010 21:56:59 +0000 (UTC)

changeset: 2596:54c9b922e200
user: Kris Maglione <kris_AT_suckless.org>
date: Fri Jan 22 20:56:00 2010 -0500
files: cmd/wmii/client.c cmd/wmii/fns.h cmd/wmii/fs.c cmd/wmii/view.c
description:
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.

diff -r 0ff28da1138c -r 54c9b922e200 cmd/wmii/client.c
--- a/cmd/wmii/client.c Fri Jan 22 19:31:26 2010 -0500
+++ b/cmd/wmii/client.c Fri Jan 22 20:56:00 2010 -0500
@@ -196,11 +196,23 @@
         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 @@
                 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 @@
         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 @@
                 add = false;
         }
 
+ found = false;
+
         j = 0;
         while(buf[n] && n < sizeof(buf) && j < 32) {
                 /* Check for regex. */
@@ -1103,6 +1116,7 @@
                                         last = buf[i];
                                         buf[i] = '\0';
 
+ found = true;
                                         goto next;
                                 }
                         }
@@ -1129,9 +1143,10 @@
                         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 @@
         p = comm(~0, c->retags, toks);
         client_setviews(c, p);
         free(p);
+ return found;
 }
 
-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;
- }
-}
-
diff -r 0ff28da1138c -r 54c9b922e200 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Fri Jan 22 19:31:26 2010 -0500
+++ b/cmd/wmii/fns.h Fri Jan 22 20:56:00 2010 -0500
@@ -68,8 +68,7 @@
 
 /* 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 -r 0ff28da1138c -r 54c9b922e200 cmd/wmii/fs.c
--- a/cmd/wmii/fs.c Fri Jan 22 19:31:26 2010 -0500
+++ b/cmd/wmii/fs.c Fri Jan 22 20:56:00 2010 -0500
@@ -535,7 +535,7 @@
                 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 -r 0ff28da1138c -r 54c9b922e200 cmd/wmii/view.c
--- a/cmd/wmii/view.c Fri Jan 22 19:31:26 2010 -0500
+++ b/cmd/wmii/view.c Fri Jan 22 20:56:00 2010 -0500
@@ -96,7 +96,7 @@
         /* 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 @@
         /* 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);
Received on Sat Jan 23 2010 - 21:56:59 UTC

This archive was generated by hypermail 2.2.0 : Sat Jan 23 2010 - 22:00:13 UTC