2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
10 #include <sys/types.h>
11 #include <X11/Xutil.h>
15 const char *clpattern;
30 static RReg *rreg = NULL;
31 static unsigned int len = 0;
38 for(; c && !isvisible(c); c = c->next);
45 for(; c && !isvisible(c); c = c->prev);
57 len = sizeof(rule) / sizeof(rule[0]);
58 rreg = emallocz(len * sizeof(RReg));
60 for(i = 0; i < len; i++) {
61 if(rule[i].clpattern) {
62 reg = emallocz(sizeof(regex_t));
63 if(regcomp(reg, rule[i].clpattern, 0))
66 rreg[i].clregex = reg;
68 if(rule[i].tpattern) {
69 reg = emallocz(sizeof(regex_t));
70 if(regcomp(reg, rule[i].tpattern, 0))
79 settags(Client *c, Client *trans)
84 Bool matched = trans != NULL;
88 for(i = 0; i < ntags; i++)
89 c->tags[i] = trans->tags[i];
91 else if(XGetClassHint(dpy, c->win, &ch)) {
92 snprintf(prop, sizeof(prop), "%s:%s:%s",
93 ch.res_class ? ch.res_class : "",
94 ch.res_name ? ch.res_name : "", c->name);
95 for(i = 0; !matched && i < len; i++)
96 if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) {
97 c->isfloat = rule[i].isfloat;
98 for(j = 0; rreg[i].tregex && j < ntags; j++) {
99 if(!regexec(rreg[i].tregex, tags[j], 1, &tmp, 0)) {
111 for(i = 0; i < ntags; i++)
112 c->tags[i] = seltag[i];
113 for(c->weight = 0; c->weight < ntags && !c->tags[c->weight]; c->weight++);
124 for(i = 0; i < ntags; i++)
125 sel->tags[i] = False;
126 sel->tags[arg->i] = True;
127 sel->weight = arg->i;
139 sel->tags[arg->i] = !sel->tags[arg->i];
140 for(i = 0; i < ntags && !sel->tags[i]; i++);
142 sel->tags[arg->i] = True;
143 sel->weight = (i == ntags) ? arg->i : i;