wmii

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

commit 8e61f1b4968c9f6f79d60bfc0213c762735b7b15
parent b72f13580c35d9dfdd6f114f2f7a035d66404c2c
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Wed, 15 Mar 2006 13:18:05 +0100

multitag syntax for select and tags file is allowed now with tag[+tag[+tag]...], spaces don't separate tags anymore!!!


Diffstat:
cmd/wm/client.c | 21+++++++++++----------
cmd/wm/fs.c | 6+-----
cmd/wm/tag.c | 59+++++++++++++++++++++++++++++++++--------------------------
cmd/wm/wm.h | 3++-
rc/wmiirc | 2+-
5 files changed, 48 insertions(+), 43 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -215,7 +215,6 @@ draw_client(Client *c) { Draw d = { 0 }; char buf[512]; - unsigned int i; if(!c->nframe) return; /* might not have been attached atm */ @@ -243,11 +242,9 @@ draw_client(Client *c) d.rect.width = c->frame[c->sel]->rect.width; d.rect.height = bar_height(); d.notch = nil; - buf[0] = 0; - for(i = 0; i < c->ntag; i++) { - cext_strlcat(buf, c->tag[i], sizeof(buf)); - cext_strlcat(buf, " | ", sizeof(buf)); - } + + tags2str(buf, sizeof(buf), c->tag, c->ntag); + cext_strlcat(buf, " | ", sizeof(buf)); cext_strlcat(buf, c->name, sizeof(buf) - strlen(buf)); d.data = buf; blitz_drawlabel(dpy, &d); @@ -335,12 +332,16 @@ manage_client(Client *c) t = ntag ? tag[sel] : alloc_tag(def.tag); if(!c->ntag) { - cext_strlcpy(c->tag[0], t->name, sizeof(c->tag[0])); - c->ntag++; + for(i = 0; i < t->ntag; i++) { + cext_strlcpy(c->tag[i], t->tag[i], sizeof(c->tag[i])); + c->ntag++; + } } else if((c->ntag == 1) && !strncmp(c->tag[0], "~", 2)) { - cext_strlcpy(c->tag[1], t->name, sizeof(c->tag[1])); - c->ntag++; + for(i = 0; i < t->ntag && i + 1 < MAX_TAGS; i++) { + cext_strlcpy(c->tag[i + 1], t->tag[i], sizeof(c->tag[i + 1])); + c->ntag++; + } } update_tags(); diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -153,11 +153,7 @@ qid2name(Qid *qid) case FsDws: if(qid->dir_type == FsDroot) return "ws"; - else { - if(i1 == -1) - return nil; - return tag[i1]->name; - } + return nil; break; case FsDlabel: if(i1 == -1) diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c @@ -27,7 +27,7 @@ alloc_tag(char *name) Tag *t = cext_emallocz(sizeof(Tag)); t->id = id++; - cext_strlcpy(t->name, name, sizeof(t->name)); + t->ntag = str2tags(t->tag, name); alloc_area(t); alloc_area(t); tag = (Tag **)cext_array_attach((void **)tag, t, sizeof(Tag *), &tagsz); @@ -70,7 +70,8 @@ tag2index(Tag *t) void focus_tag(Tag *t) { - char buf[16]; + char buf[256]; + char name[256]; int i, j; if(!ntag) @@ -98,7 +99,8 @@ focus_tag(Tag *t) else XMoveWindow(dpy, client[i]->framewin, 2 * rect.width + f->rect.x, f->rect.y); } - snprintf(buf, sizeof(buf), "FocusTag %s\n", t->name); + tags2str(name, sizeof(name), t->tag, t->ntag); + snprintf(buf, sizeof(buf), "FocusTag %s\n", name); write_event(buf); XSync(dpy, False); XUngrabServer(dpy); @@ -148,31 +150,29 @@ tid2index(unsigned short id) Tag * get_tag(char *name) { - unsigned int i, n = 0, j, nt; + unsigned int i, j, ntags; Tag *t = nil; - char buf[256]; - char *tags[8]; + char tname[256]; + char tags[MAX_TAGS][MAX_TAGLEN]; for(i = 0; i < ntag; i++) { t = tag[i]; - if(!strncmp(t->name, name, strlen(name))) + tags2str(tname, sizeof(tname), t->tag, t->ntag); + if(!strncmp(tname, name, strlen(name))) return t; } - cext_strlcpy(buf, name, sizeof(buf)); - nt = cext_tokenize(tags, 8, buf, ' '); + ntags = str2tags(tags, name); for(i = 0; i < nclient; i++) - for(j = 0; j < nt; j++) - if(clienthastag(client[i], tags[j])) { - n++; - break; - } - if(!n) - return nil; + for(j = 0; j < ntags; j++) + if(clienthastag(client[i], tags[j])) + goto Createtag; + return nil; +Createtag: t = alloc_tag(name); for(i = 0; i < nclient; i++) - for(j = 0; j < nt; j++) + for(j = 0; j < ntags; j++) if(clienthastag(client[i], tags[j]) && !clientoftag(t, client[i])) attach_totag(t, client[i]); return t; @@ -187,7 +187,6 @@ select_tag(char *arg) if(!t) return; - focus_tag(t); cext_strlcpy(def.tag, arg, sizeof(def.tag)); if(!istag(ctag, nctag, arg)) { char buf[256]; @@ -197,6 +196,7 @@ select_tag(char *arg) snprintf(buf, sizeof(buf), "NewTag %s\n", arg); write_event(buf); } + focus_tag(t); for(i = 0; i < ntag; i++) { n = 0; @@ -225,7 +225,7 @@ clientoftag(Tag *t, Client *c) void update_tags() { - unsigned int i, j; + unsigned int i, j, k; char buf[256]; char **newctag = nil; @@ -265,14 +265,21 @@ update_tags() for(i = 0; i < nclient; i++) for(j = 0; j < ntag; j++) { - if(!clienthastag(client[i], tag[j]->name)) { - if(clientoftag(tag[j], client[i])) - detach_fromtag(tag[j], client[i]); - } - else { + Bool hastag = False; + for(k = 0; k < tag[j]->ntag; k++) { + if(clienthastag(client[i], tag[j]->tag[k])) + hastag = True; + break; + } + + if(hastag) { if(!clientoftag(tag[j], client[i])) attach_totag(tag[j], client[i]); } + else { + if(clientoftag(tag[j], client[i])) + detach_fromtag(tag[j], client[i]); + } } if(!ntag && nctag) @@ -358,7 +365,7 @@ str2tags(char tags[MAX_TAGS][MAX_TAGLEN], const char *stags) char *toks[MAX_TAGS]; cext_strlcpy(buf, stags, sizeof(buf)); - n = cext_tokenize(toks, MAX_TAGS, buf, ' '); + n = cext_tokenize(toks, MAX_TAGS, buf, '+'); for(i = 0; i < n; i++) cext_strlcpy(tags[i], toks[i], MAX_TAGLEN); return n; @@ -376,7 +383,7 @@ tags2str(char *stags, unsigned int stagsz, if(len + l + 1 >= stagsz) return; if(len) - stags[len++] = ' '; + stags[len++] = '+'; memcpy(stags + len, tags[i], l); len += l; stags[len] = 0; diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -89,7 +89,8 @@ typedef struct Frame Frame; typedef struct Client Client; struct Tag { - char name[256]; + char tag[MAX_TAGS][MAX_TAGLEN]; + unsigned int ntag; unsigned short id; Area **area; unsigned int areasz; diff --git a/rc/wmiirc b/rc/wmiirc @@ -118,7 +118,7 @@ do then xwrite /bar/$oldtag/colors $WMII_SELCOLORS fi - xwrite /bar/$1/data $1 + xwrite /bar/$1/data "$1" xwrite /bar/$1/colors $WMII_NORMCOLORS oldtag=$1;; LabelClick)