1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
2 * See LICENSE file for license details.
10 #include <X11/Xutil.h>
14 const char *clpattern;
29 static RReg *rreg = NULL;
30 static unsigned int len = 0;
36 for(; c && !isvisible(c); c = c->next);
42 for(; c && !isvisible(c); c = c->prev);
53 len = sizeof rule / sizeof rule[0];
54 rreg = emallocz(len * sizeof(RReg));
55 for(i = 0; i < len; i++) {
56 if(rule[i].clpattern) {
57 reg = emallocz(sizeof(regex_t));
58 if(regcomp(reg, rule[i].clpattern, REG_EXTENDED))
61 rreg[i].clregex = reg;
63 if(rule[i].tpattern) {
64 reg = emallocz(sizeof(regex_t));
65 if(regcomp(reg, rule[i].tpattern, REG_EXTENDED))
74 settags(Client *c, Client *trans) {
78 Bool matched = trans != NULL;
79 XClassHint ch = { 0 };
82 for(i = 0; i < ntags; i++)
83 c->tags[i] = trans->tags[i];
85 XGetClassHint(dpy, c->win, &ch);
86 snprintf(prop, sizeof prop, "%s:%s:%s",
87 ch.res_class ? ch.res_class : "",
88 ch.res_name ? ch.res_name : "", c->name);
89 for(i = 0; i < len; i++)
90 if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) {
91 c->isfloat = rule[i].isfloat;
92 for(j = 0; rreg[i].tregex && j < ntags; j++) {
93 if(!regexec(rreg[i].tregex, tags[j], 1, &tmp, 0)) {
105 for(i = 0; i < ntags; i++)
106 c->tags[i] = seltag[i];
115 for(i = 0; i < ntags; i++)
116 sel->tags[i] = (arg->i == -1) ? True : False;
117 if(arg->i >= 0 && arg->i < ntags)
118 sel->tags[arg->i] = True;
123 toggletag(Arg *arg) {
128 sel->tags[arg->i] = !sel->tags[arg->i];
129 for(i = 0; i < ntags && !sel->tags[i]; i++);
131 sel->tags[arg->i] = True;