From 72c0efea9e4aac99159fb8a467ce5622cfd49ccf Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Mon, 10 Apr 2006 10:58:21 +0200 Subject: [PATCH] removed /view/tag, removed -t argument, instead /def/rules is used. A new magic tag "!" keeps track of inheriting the selected view tag (/.*/ -> !), the first rule /.*/ -> 1 replaces the /view/tag default tag stuff (ex -t argument), writing "retag" to /ctl applies /def/rule to all existing clients, except the "!" handling --- cmd/wm/area.c | 2 ++ cmd/wm/bar.c | 2 +- cmd/wm/client.c | 10 +--------- cmd/wm/fs.c | 22 +++------------------- cmd/wm/rule.c | 14 ++++++++++---- cmd/wm/tag.c | 10 ++++++++++ cmd/wm/view.c | 2 -- cmd/wm/wm.c | 12 +++--------- cmd/wm/wm.h | 5 ++--- cmd/wm/wmii | 12 +----------- rc/wmiirc | 3 +++ 11 files changed, 36 insertions(+), 58 deletions(-) diff --git a/cmd/wm/area.c b/cmd/wm/area.c index 2b543331..708e65cc 100644 --- a/cmd/wm/area.c +++ b/cmd/wm/area.c @@ -142,6 +142,7 @@ typedef struct { void place_client(Area *a, Client *c) { +#if 0 static Gravity gravity[] = { {0, 0}, /* CENTER */ @@ -155,6 +156,7 @@ place_client(Area *a, Client *c) {-1, 0} /* W */ }; unsigned int dx = rect.width / 3, dy = rect.height / 3; +#endif Frame *f = c->frame.data[c->sel]; if(c->trans) return; diff --git a/cmd/wm/bar.c b/cmd/wm/bar.c index 982541a3..91c1abe2 100644 --- a/cmd/wm/bar.c +++ b/cmd/wm/bar.c @@ -118,7 +118,7 @@ draw_bar() for(i = 0; (i < label.size) && (w < brect.width); i++) { l = label.data[i]; if(l->intern) { - if(view.size && !strncmp(l->name, def.tag, sizeof(l->name))) + if(view.size && !strncmp(l->name, view.data[sel]->name, sizeof(l->name))) l->color = def.sel; else l->color = def.norm; diff --git a/cmd/wm/client.c b/cmd/wm/client.c index 78c284a6..35f2d4a3 100644 --- a/cmd/wm/client.c +++ b/cmd/wm/client.c @@ -328,7 +328,6 @@ gravitate(Client *c, Bool invert) void manage_client(Client *c) { - View *v; Client *trans; if(c->trans && (trans = win2client(c->trans))) { @@ -336,16 +335,9 @@ manage_client(Client *c) str2tagvector(&c->tag, c->tags); } else - match_tags(c); + match_tags(c, True); reparent_client(c, c->framewin, c->rect.x, c->rect.y); - - v = view.size ? view.data[sel] : alloc_view(def.tag); - if(!strlen(c->tags)) { - cext_strlcpy(c->tags, v->name, sizeof(c->tags)); - str2tagvector(&c->tag, c->tags); - } - update_tags(); } diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c index 931155de..e7b339d7 100644 --- a/cmd/wm/fs.c +++ b/cmd/wm/fs.c @@ -49,7 +49,6 @@ enum { WMII_IOUNIT = 2048 }; * /event FsFevent * /ctl FsFctl command interface (root) * /view/ FsDview view - * /view/tag FsFtag current tag * /view/ctl FsFctl command interface (tag) * /view/sel/ FsDarea * /view/1/ FsDarea @@ -271,8 +270,6 @@ name2type(char *name, unsigned char dir_type) return FsFdata; if(!strncmp(name, "mode", 5)) return FsFmode; - if(!strncmp(name, "tag", 4)) - return FsFtag; if((dir_type == FsDbar) && name2label(name)) return FsDlabel; if(!strncmp(name, "sel", 4)) @@ -386,11 +383,6 @@ mkqid(Qid *dir, char *wname, Qid *new) return -1; goto Mkfile; break; - case FsFtag: - if(dir_i1 == -1 || dir_type != FsDview) - return -1; - goto Mkfile; - break; case FsFgeom: case FsFname: case FsFclass: @@ -527,10 +519,6 @@ type2stat(Stat *stat, char *wname, Qid *dir) break; } break; - case FsFtag: - if(dir_type == FsDview) - return mkstat(stat, dir, wname, strlen(def.tag), IXP_DMREAD); - break; case FsFdata: return mkstat(stat, dir, wname, (dir_i1 == label.size) ? 0 : strlen(label.data[dir_i1]->data), IXP_DMREAD | IXP_DMWRITE); @@ -761,7 +749,7 @@ xread(IXPConn *c, Fcall *fcall) break; case FsDview: /* jump to offset */ - len = type2stat(&stat, "tag", &m->qid); + len = 0; if(view.size) { len += type2stat(&stat, "ctl", &m->qid); if(view.data[i1]->area.size) @@ -929,8 +917,6 @@ xread(IXPConn *c, Fcall *fcall) p = ixp_enc_stat(p, &stat); break; case FsDview: - fcall->count = type2stat(&stat, "tag", &m->qid); - p = ixp_enc_stat(p, &stat); if(view.size) { fcall->count += type2stat(&stat, "ctl", &m->qid); p = ixp_enc_stat(p, &stat); @@ -1059,10 +1045,6 @@ xread(IXPConn *c, Fcall *fcall) if((fcall->count = strlen(label.data[i1]->data))) memcpy(p, label.data[i1]->data, fcall->count); break; - case FsFtag: - if((fcall->count = strlen(def.tag))) - memcpy(p, def.tag, fcall->count); - break; case FsFcolors: if(i1 >= label.size) return Enofile; @@ -1171,6 +1153,8 @@ xwrite(IXPConn *c, Fcall *fcall) srv.running = 0; else if(!strncmp(buf, "view ", 5)) select_view(&buf[5]); + else if(!strncmp(buf, "retag", 6)) + retag(); else return Enocommand; break; diff --git a/cmd/wm/rule.c b/cmd/wm/rule.c index dfac21eb..f99a197d 100644 --- a/cmd/wm/rule.c +++ b/cmd/wm/rule.c @@ -99,7 +99,7 @@ update_rules() static void -match(Client *c, const char *prop) +match(Client *c, const char *prop, Bool newclient) { unsigned int i; regmatch_t tmpregm; @@ -109,6 +109,12 @@ match(Client *c, const char *prop) if(r->is_valid && !regexec(&r->regex, prop, 1, &tmpregm, 0)) { if(!strncmp(r->tags, "~", 2)) c->floating = True; + else if(!strncmp(r->tags, "!", 2)) { + if(view.size && newclient) { + cext_strlcpy(c->tags, view.data[sel]->name, sizeof(c->tags)); + str2tagvector(&c->tag, c->tags); + } + } else { cext_strlcpy(c->tags, r->tags, sizeof(c->tags)); str2tagvector(&c->tag, c->tags); @@ -118,10 +124,10 @@ match(Client *c, const char *prop) } void -match_tags(Client *c) +match_tags(Client *c, Bool newclient) { if(!def.rules) return; - match(c, c->name); - match(c, c->classinst); + match(c, c->name, newclient); + match(c, c->classinst, newclient); } diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c index e77c206d..69e9c64c 100644 --- a/cmd/wm/tag.c +++ b/cmd/wm/tag.c @@ -105,3 +105,13 @@ str2tagvector(TagVector *tv, const char *tags) for(i = 0; i < n; i++) cext_vattach(tag2vector(tv), strdup(toks[i])); } + +void +retag() +{ + unsigned int i; + for(i = 0; i < client.size; i++) + match_tags(client.data[i], False); + update_tags(); +} + diff --git a/cmd/wm/view.c b/cmd/wm/view.c index b06567fd..fd967845 100644 --- a/cmd/wm/view.c +++ b/cmd/wm/view.c @@ -81,8 +81,6 @@ focus_view(View *v) XGrabServer(dpy); sel = view2index(v); - cext_strlcpy(def.tag, v->name, sizeof(def.tag)); - update_frame_selectors(v); /* gives all(!) clients proper geometry (for use of different tags) */ diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c index 1e6ed594..24b767f5 100644 --- a/cmd/wm/wm.c +++ b/cmd/wm/wm.c @@ -24,7 +24,7 @@ static char version[] = "wmiiwm - " VERSION ", (C)opyright MMIV-MMVI Anselm R. G static void usage() { - fprintf(stderr, "%s", "usage: wmiiwm -a
[-t ] [-c] [-v]\n"); + fprintf(stderr, "%s", "usage: wmiiwm -a
[-c] [-v]\n"); exit(1); } @@ -219,7 +219,6 @@ main(int argc, char *argv[]) XSetWindowAttributes wa; /* command line args */ - def.tag[0] = 0; if(argc > 1) { for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) { switch (argv[i][1]) { @@ -230,9 +229,6 @@ main(int argc, char *argv[]) case 'c': checkwm = 1; break; - case 't': - cext_strlcpy(def.tag, argv[++i], sizeof(def.tag)); - break; case 'a': if(i + 1 < argc) address = argv[++i]; @@ -302,14 +298,12 @@ main(int argc, char *argv[]) key.size = 0; label.data = nil; label.size = 0; - def.rules = nil; - def.rulessz = 0; + def.rules = strdup("/.*/ -> 1\n/.*/ -> !"); + def.rulessz = strlen(def.rules); def.keys = nil; def.keyssz = 0; def.font = strdup(BLITZ_FONT); def.border = 2; - if(!strlen(def.tag)) - cext_strlcpy(def.tag, "1", sizeof(def.tag)); cext_strlcpy(def.selcolor, BLITZ_SELCOLORS, sizeof(def.selcolor)); blitz_loadcolor(dpy, screen, def.selcolor, &def.sel); cext_strlcpy(def.normcolor, BLITZ_NORMCOLORS, sizeof(def.normcolor)); diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h index 1e372cef..54688dee 100644 --- a/cmd/wm/wm.h +++ b/cmd/wm/wm.h @@ -59,7 +59,6 @@ enum { FsFrules, FsFtags, FsFclass, - FsFtag, FsFmode }; @@ -141,7 +140,6 @@ typedef struct { typedef struct { char selcolor[24]; char normcolor[24]; - char tag[256]; char *font; Color sel; Color norm; @@ -263,13 +261,14 @@ void ungrab_mouse(Window w, unsigned long mod, unsigned int button); /* rule.c */ void update_rules(); -void match_tags(Client *c); +void match_tags(Client *c, Bool newclient); /* tag.c */ Bool istag(char *t); void ensure_tag(char *t); void update_tags(); void str2tagvector(TagVector *tv, const char *tags); +void retag(); /* view.c */ void arrange_view(View *v, Bool dirty); diff --git a/cmd/wm/wmii b/cmd/wm/wmii index 1b3f52a6..40166e8c 100644 --- a/cmd/wm/wmii +++ b/cmd/wm/wmii @@ -3,22 +3,12 @@ wmiiwm -c || exit 1 -t= -if test $# -eq 2 && test "X$1" = X-t -then - t="-t $2" -elif test $# -ne 0 -then - echo "usage: wmii [-t tag]" >&2 - exit 1 -fi - OLD_PATH=$PATH export OLD_PATH PATH=$HOME/.wmii-3:CONFPREFIX/wmii-3:$PATH export PATH WMII_ADDRESS=unix!/tmp/ns.$USER.$DISPLAY/wmii export WMII_ADDRESS mkdir -m 700 /tmp/ns.$USER.$DISPLAY 2>/dev/null -wmiiwm -a $WMII_ADDRESS $t & +wmiiwm -a $WMII_ADDRESS & wmiiwmpid=$! mkdir $HOME/.wmii-3 2>/dev/null && welcome & wmiirc & diff --git a/rc/wmiirc b/rc/wmiirc index 165e61c1..40e31b1f 100644 --- a/rc/wmiirc +++ b/rc/wmiirc @@ -31,9 +31,12 @@ xwrite /def/normcolors $WMII_NORMCOLORS # TAGGING RULES wmiir write /def/rules < 1 +/.*/ -> ! /XMMS:.*/ -> ~ /Gimp.*:.*/ -> ~ EOF +xwrite /ctl retag # MISC xsetroot -solid '#0b1014'