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.*", { [Twww] = "www" }, False },
25 { "Gimp.*", { 0 }, True},
32 [Tscratch] = "scratch",
37 void (*arrange)(Arg *) = dotile;
45 sel->tags[arg->i] = tags[arg->i];
54 for(c = clients; c; c = c->next) {
57 resize(c, True, TopLeft);
62 if(sel && !sel->tags[tsel]) {
63 if((sel = getnext(clients, tsel))) {
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);
98 c->w = sw - 2 * c->border;
99 c->h = sh - 2 * c->border - bh;
104 c->w = mw - 2 * c->border;
105 c->h = sh - 2 * c->border - bh;
109 c->y = sy + (i - 1) * h + bh;
110 c->w = w - 2 * c->border;
111 c->h = h - 2 * c->border;
113 else { /* fallback if h < bh */
116 c->w = w - 2 * c->border;
117 c->h = sh - 2 * c->border - bh;
119 resize(c, False, TopLeft);
125 if(!sel || (sel && !sel->tags[tsel])) {
126 if((sel = getnext(clients, tsel))) {
135 getnext(Client *c, unsigned int t)
137 for(; c && !c->tags[t]; c = c->next);
150 if(!(c = getnext(clients, arg->i)))
153 for(i = 0; i < TLast; i++)
155 c->tags[tsel] = tags[tsel];
168 for(i = 0; i < TLast; i++)
177 static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0;
181 Bool matched = False;
185 c->tags[tsel] = tags[tsel];
189 if(XGetClassHint(dpy, c->win, &ch)) {
190 snprintf(classinst, sizeof(classinst), "%s:%s",
191 ch.res_class ? ch.res_class : "",
192 ch.res_name ? ch.res_name : "");
193 for(i = 0; !matched && i < len; i++) {
194 if(!regcomp(®ex, rule[i].pattern, 0)) {
195 if(!regexec(®ex, classinst, 1, &tmp, 0)) {
196 for(j = 0; j < TLast; j++) {
199 c->tags[j] = rule[i].tags[j];
201 c->isfloat = rule[i].isfloat;
212 c->tags[tsel] = tags[tsel];
218 arrange = arrange == dofloat ? dotile : dofloat;