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;
33 void (*arrange)(Arg *) = DEFMODE;
43 sel->tags[arg->i] = True;
52 for(c = clients; c; c = c->next) {
55 resize(c, True, TopLeft);
60 if(sel && !sel->tags[tsel]) {
61 if((sel = getnext(clients))) {
66 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
78 for(n = 0, c = clients; c; c = c->next)
79 if(c->tags[tsel] && !c->isfloat)
83 h = (sh - bh) / (n - 1);
87 for(i = 0, c = clients; c; c = c->next) {
92 resize(c, True, TopLeft);
109 c->y = sy + (i - 1) * h + bh;
113 else { /* fallback if h < bh */
119 resize(c, False, TopLeft);
125 if(!sel || (sel && !sel->tags[tsel])) {
126 if((sel = getnext(clients))) {
131 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
139 for(; c && !c->tags[tsel]; c = c->next);
146 for(; c && !c->tags[tsel]; c = c->prev);
158 len = sizeof(rule) / sizeof(rule[0]);
159 rreg = emallocz(len * sizeof(RReg));
161 for(i = 0; i < len; i++) {
162 if(rule[i].clpattern) {
163 reg = emallocz(sizeof(regex_t));
164 if(regcomp(reg, rule[i].clpattern, 0))
167 rreg[i].clregex = reg;
169 if(rule[i].tpattern) {
170 reg = emallocz(sizeof(regex_t));
171 if(regcomp(reg, rule[i].tpattern, 0))
174 rreg[i].tregex = reg;
187 for(i = 0; i < ntags; i++)
188 sel->tags[i] = False;
198 Bool matched = False;
201 if(XGetClassHint(dpy, c->win, &ch)) {
202 snprintf(classinst, sizeof(classinst), "%s:%s",
203 ch.res_class ? ch.res_class : "",
204 ch.res_name ? ch.res_name : "");
205 for(i = 0; !matched && i < len; i++)
206 if(rreg[i].clregex && !regexec(rreg[i].clregex, classinst, 1, &tmp, 0)) {
207 c->isfloat = rule[i].isfloat;
208 for(j = 0; rreg[i].tregex && j < ntags; j++) {
209 if(!regexec(rreg[i].tregex, tags[j], 1, &tmp, 0)) {
221 c->tags[tsel] = True;
227 arrange = arrange == dofloat ? dotile : dofloat;
242 arg->i = (tsel < ntags-1) ? tsel+1 : 0;
249 arg->i = (tsel > 0) ? tsel-1 : ntags-1;