wmii

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

commit 3d0b3a41da573e44a07d35e041819cc5679a378e
parent ae43c939d83a8b78079151835c90261aa5e6d12f
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Tue, 14 Mar 2006 08:53:56 +0100

fixed several issue


Diffstat:
cmd/wm/client.c | 16++++------------
cmd/wm/tag.c | 30++++++++++++++----------------
2 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -326,20 +326,12 @@ manage_client(Client *c) t = ntag ? tag[sel] : alloc_tag(def.tag); if(c->tags[0] == 0) cext_strlcpy(c->tags, t->name, sizeof(c->tags)); + else if(!strncmp(c->tags, "~", 2)) { + c->tags[1] = ' '; + cext_strlcpy(c->tags + 2, t->name, sizeof(c->tags) - 2); + } update_tags(); - - /* shorthand proposed by Georg Neis */ - if(!sel_client_of_tag(t)) { - /* consider removing the empty tag page instead */ - char ct[256]; - char *p; - - cext_strlcpy(ct, t->name, sizeof(ct)); - if((p = strchr(ct, ' '))) - *p = 0; - select_tag(ct); - } } static int diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c @@ -10,6 +10,16 @@ #include "wm.h" +static Bool +istag(char **tags, unsigned int ntags, char *tag) +{ + unsigned int i; + for(i = 0; i < ntags; i++) + if(!strncmp(tags[i], tag, strlen(tags[i]))) + return True; + return False; +} + Tag * alloc_tag(char *name) { @@ -135,16 +145,6 @@ tid2index(unsigned short id) return -1; } -static Bool -istag(char **tags, char *tag, unsigned int ntags) -{ - unsigned int i; - for(i = 0; i < ntags; i++) - if(!strncmp(tags[i], tag, strlen(tags[i]))) - return True; - return False; -} - Tag * get_tag(char *name) { @@ -153,7 +153,6 @@ get_tag(char *name) char buf[256]; char *tags[128]; - fprintf(stderr, "get_tag %s\n", name); for(i = 0; i < ntag; i++) { t = tag[i]; if(!strncmp(t->name, name, strlen(name))) @@ -162,14 +161,12 @@ get_tag(char *name) cext_strlcpy(buf, name, sizeof(buf)); nt = cext_tokenize(tags, 128, buf, '+'); - fprintf(stderr, "get_tag nt=%d\n", nt); for(i = 0; i < nclient; i++) for(j = 0; j < nt; j++) if(strstr(client[i]->tags, tags[j])) n++; - fprintf(stderr, "get_tag n=%d\n", n); if(!n) return nil; @@ -235,7 +232,7 @@ update_tags() for(k = 0; k < j; k++) { if(!strncmp(tags[k], "~", 2)) /* magic floating tag */ continue; - if(!istag(newctag, tags[k], nnewctag)) { + if(!istag(newctag, nnewctag, tags[k])) { newctag = (char **)cext_array_attach((void **)newctag, strdup(tags[k]), sizeof(char *), &newctagsz); nnewctag++; @@ -245,17 +242,18 @@ update_tags() /* propagate tagging events */ for(i = 0; i < nnewctag; i++) - if(!istag(ctag, newctag[i], nctag)) { + if(!istag(ctag, nctag, newctag[i])) { snprintf(buf, sizeof(buf), "NewTag %s\n", newctag[i]); write_event(buf); } for(i = 0; i < nctag; i++) { - if(!istag(newctag, ctag[i], nnewctag)) { + if(!istag(newctag, nnewctag, ctag[i])) { snprintf(buf, sizeof(buf), "RemoveTag %s\n", ctag[i]); write_event(buf); } free(ctag[i]); } + free(ctag); ctag = newctag; nctag = nnewctag;