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},
29 [Tscratch] = "scratch",
35 void (*arrange)(Arg *) = dotile;
47 sel->tags[arg->i] = tags[arg->i];
56 for(c = clients; c; c = c->next) {
59 resize(c, True, TopLeft);
64 if(sel && !sel->tags[tsel]) {
65 if((sel = getnext(clients, tsel))) {
80 for(n = 0, c = clients; c; c = c->next)
81 if(c->tags[tsel] && !c->isfloat)
85 h = (sh - bh) / (n - 1);
89 for(i = 0, c = clients; c; c = c->next) {
94 resize(c, True, TopLeft);
100 c->w = sw - 2 * c->border;
101 c->h = sh - 2 * c->border - bh;
106 c->w = mw - 2 * c->border;
107 c->h = sh - 2 * c->border - bh;
111 c->y = sy + (i - 1) * h + bh;
112 c->w = w - 2 * c->border;
113 c->h = h - 2 * c->border;
115 else { /* fallback if h < bh */
118 c->w = w - 2 * c->border;
119 c->h = sh - 2 * c->border - bh;
121 resize(c, False, TopLeft);
127 if(!sel || (sel && !sel->tags[tsel])) {
128 if((sel = getnext(clients, tsel))) {
137 getnext(Client *c, unsigned int t)
139 for(; c && !c->tags[t]; c = c->next);
146 for(; c && !c->tags[tsel]; c = c->prev);
159 if(!(c = getnext(clients, arg->i)))
162 for(i = 0; i < TLast; i++)
164 c->tags[tsel] = tags[tsel];
177 for(i = 0; i < TLast; i++)
186 static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0;
190 Bool matched = False;
194 c->tags[tsel] = tags[tsel];
198 if(XGetClassHint(dpy, c->win, &ch)) {
199 snprintf(classinst, sizeof(classinst), "%s:%s",
200 ch.res_class ? ch.res_class : "",
201 ch.res_name ? ch.res_name : "");
202 for(i = 0; !matched && i < len; i++) {
203 if(!regcomp(®ex, rule[i].pattern, 0)) {
204 if(!regexec(®ex, classinst, 1, &tmp, 0)) {
205 for(j = 0; j < TLast; j++) {
208 c->tags[j] = rule[i].tags[j];
210 c->isfloat = rule[i].isfloat;
221 c->tags[tsel] = tags[tsel];
227 arrange = arrange == dofloat ? dotile : dofloat;