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>
22 static Rule rule[] = {
23 /* class:instance tags isfloat */
24 { "Firefox.*", { [Tnet] = "net" }, False },
25 { "Gimp.*", { 0 }, True},
36 void (*arrange)(Arg *) = dotile;
48 sel->tags[arg->i] = tags[arg->i];
57 for(c = clients; c; c = c->next) {
60 resize(c, True, TopLeft);
65 if(sel && !sel->tags[tsel]) {
66 if((sel = getnext(clients))) {
71 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
83 for(n = 0, c = clients; c; c = c->next)
84 if(c->tags[tsel] && !c->isfloat)
88 h = (sh - bh) / (n - 1);
92 for(i = 0, c = clients; c; c = c->next) {
97 resize(c, True, TopLeft);
103 c->w = sw - 2 * c->border;
104 c->h = sh - 2 * c->border - bh;
109 c->w = mw - 2 * c->border;
110 c->h = sh - 2 * c->border - bh;
114 c->y = sy + (i - 1) * h + bh;
115 c->w = w - 2 * c->border;
116 c->h = h - 2 * c->border;
118 else { /* fallback if h < bh */
121 c->w = w - 2 * c->border;
122 c->h = sh - 2 * c->border - bh;
124 resize(c, False, TopLeft);
130 if(!sel || (sel && !sel->tags[tsel])) {
131 if((sel = getnext(clients))) {
136 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
144 for(; c && !c->tags[tsel]; c = c->next);
151 for(; c && !c->tags[tsel]; c = c->prev);
163 for(i = 0; i < TLast; i++)
172 static unsigned int len = sizeof(rule) / sizeof(rule[0]);
176 Bool matched = False;
179 if(XGetClassHint(dpy, c->win, &ch)) {
180 snprintf(classinst, sizeof(classinst), "%s:%s",
181 ch.res_class ? ch.res_class : "",
182 ch.res_name ? ch.res_name : "");
183 for(i = 0; !matched && i < len; i++) {
184 if(!regcomp(®ex, rule[i].pattern, 0)) {
185 if(!regexec(®ex, classinst, 1, &tmp, 0)) {
186 for(j = 0; j < TLast; j++) {
189 c->tags[j] = rule[i].tags[j];
191 c->isfloat = rule[i].isfloat;
202 c->tags[tsel] = tags[tsel];
208 arrange = arrange == dofloat ? dotile : dofloat;