mirror of https://github.com/0intro/wmii
tagging events: NT <tag> is written if a new tag appears in /tags, RT <tag> is written if a tag disappeared in /tags
This commit is contained in:
parent
fd9dbf43e0
commit
08f98bc26b
|
@ -159,8 +159,22 @@ detach_fromarea(Area *a, Client *c)
|
|||
if(a->nframe)
|
||||
arrange_area(a);
|
||||
else {
|
||||
if(area2index(a) && t->narea > 2)
|
||||
i = area2index(a);
|
||||
if(i && t->narea > 2)
|
||||
destroy_area(a);
|
||||
else if(!i && !a->nframe) {
|
||||
if(c->trans) {
|
||||
/* focus area of transient, if possible */
|
||||
Client *cl = win2client(c->trans);
|
||||
if(cl && cl->nframe) {
|
||||
a = cl->frame[cl->sel]->area;
|
||||
if(a->tag == t)
|
||||
t->sel = area2index(a);
|
||||
}
|
||||
}
|
||||
else if(t->area[1]->nframe)
|
||||
t->sel = 1; /* focus first col as fallback */
|
||||
}
|
||||
arrange_tag(t, True);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ name2type(char *name, unsigned char dir_type)
|
|||
return FsFmode;
|
||||
if(!strncmp(name, "tag", 4))
|
||||
return FsFtag;
|
||||
if(has_tag(name) && (dir_type == FsDtags))
|
||||
if(has_tag(ctag, name, nctag) && (dir_type == FsDtags))
|
||||
return FsFtag;
|
||||
if((dir_type == FsDclass) && name2class(name))
|
||||
return FsFclasstag;
|
||||
|
|
43
cmd/wm/tag.c
43
cmd/wm/tag.c
|
@ -139,7 +139,7 @@ get_tag(char *name)
|
|||
unsigned int i, n = 0;
|
||||
Tag *t;
|
||||
|
||||
if(!has_tag(name))
|
||||
if(!has_tag(ctag, name, nctag))
|
||||
return nil;
|
||||
for(i = 0; i < ntag; i++) {
|
||||
t = tag[i];
|
||||
|
@ -185,11 +185,11 @@ select_tag(char *arg)
|
|||
}
|
||||
|
||||
Bool
|
||||
has_tag(char *tag)
|
||||
has_tag(char **tags, char *tag, unsigned int ntags)
|
||||
{
|
||||
unsigned int i;
|
||||
for(i = 0; i < nctag; i++)
|
||||
if(!strncmp(ctag[i], tag, strlen(ctag[i])))
|
||||
for(i = 0; i < ntags; i++)
|
||||
if(!strncmp(tags[i], tag, strlen(tags[i])))
|
||||
return True;
|
||||
return False;
|
||||
}
|
||||
|
@ -212,12 +212,9 @@ update_tags()
|
|||
char *tags[128];
|
||||
char *t;
|
||||
|
||||
fprintf(stderr, "%s", "update_tags\n");
|
||||
for(i = 0; i < nctag; i++) {
|
||||
free(ctag[i]);
|
||||
ctag[i] = nil;
|
||||
}
|
||||
nctag = 0;
|
||||
char **newctag = nil;
|
||||
unsigned int newctagsz = 0;
|
||||
unsigned int nnewctag = 0;
|
||||
|
||||
for(i = 0; i < nclient; i++) {
|
||||
cext_strlcpy(buf, client[i]->tags, sizeof(buf));
|
||||
|
@ -226,14 +223,32 @@ update_tags()
|
|||
t = tags[k];
|
||||
if(*t == '~')
|
||||
t++;
|
||||
if(!has_tag(t)) {
|
||||
ctag = (char **)cext_array_attach((void **)ctag, strdup(t),
|
||||
sizeof(char *), &ctagsz);
|
||||
nctag++;
|
||||
if(!has_tag(newctag, t, nnewctag)) {
|
||||
newctag = (char **)cext_array_attach((void **)newctag, strdup(t),
|
||||
sizeof(char *), &newctagsz);
|
||||
nnewctag++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* propagate tagging events */
|
||||
for(i = 0; i < nnewctag; i++)
|
||||
if(!has_tag(ctag, newctag[i], nctag)) {
|
||||
snprintf(buf, sizeof(buf), "NT %s\n", newctag[i]);
|
||||
write_event(buf);
|
||||
}
|
||||
for(i = 0; i < nctag; i++) {
|
||||
if(!has_tag(newctag, ctag[i], nnewctag)) {
|
||||
snprintf(buf, sizeof(buf), "RT %s\n", ctag[i]);
|
||||
write_event(buf);
|
||||
}
|
||||
free(ctag[i]);
|
||||
}
|
||||
free(ctag);
|
||||
ctag = newctag;
|
||||
nctag = nnewctag;
|
||||
ctagsz = newctagsz;
|
||||
|
||||
for(i = 0; i < nclient; i++)
|
||||
for(j = 0; j < ntag; j++) {
|
||||
if(strstr(client[i]->tags, tag[j]->name)) {
|
||||
|
|
|
@ -312,7 +312,7 @@ XRectangle *rectangles(unsigned int *num);
|
|||
int tid2index(unsigned short id);
|
||||
void select_tag(char *arg);
|
||||
int tag2index(Tag *t);
|
||||
Bool has_tag(char *tag);
|
||||
Bool has_tag(char **tags, char *tag, unsigned int ntags);
|
||||
void update_tags();
|
||||
Bool clientoftag(Tag *t, Client *c);
|
||||
void detach_fromtag(Tag *t, Client *c, Bool unmap);
|
||||
|
|
Loading…
Reference in New Issue