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, tsel))) {
81 for(n = 0, c = clients; c; c = c->next)
82 if(c->tags[tsel] && !c->isfloat)
86 h = (sh - bh) / (n - 1);
90 for(i = 0, c = clients; c; c = c->next) {
95 resize(c, True, TopLeft);
101 c->w = sw - 2 * c->border;
102 c->h = sh - 2 * c->border - bh;
107 c->w = mw - 2 * c->border;
108 c->h = sh - 2 * c->border - bh;
112 c->y = sy + (i - 1) * h + bh;
113 c->w = w - 2 * c->border;
114 c->h = h - 2 * c->border;
116 else { /* fallback if h < bh */
119 c->w = w - 2 * c->border;
120 c->h = sh - 2 * c->border - bh;
122 resize(c, False, TopLeft);
128 if(!sel || (sel && !sel->tags[tsel])) {
129 if((sel = getnext(clients, tsel))) {
138 getnext(Client *c, unsigned int t)
140 for(; c && !c->tags[t]; c = c->next);
147 for(; c && !c->tags[tsel]; c = c->prev);
159 for(i = 0; i < TLast; i++)
168 static unsigned int len = sizeof(rule) / sizeof(rule[0]);
172 Bool matched = False;
175 if(XGetClassHint(dpy, c->win, &ch)) {
176 snprintf(classinst, sizeof(classinst), "%s:%s",
177 ch.res_class ? ch.res_class : "",
178 ch.res_name ? ch.res_name : "");
179 for(i = 0; !matched && i < len; i++) {
180 if(!regcomp(®ex, rule[i].pattern, 0)) {
181 if(!regexec(®ex, classinst, 1, &tmp, 0)) {
182 for(j = 0; j < TLast; j++) {
185 c->tags[j] = rule[i].tags[j];
187 c->isfloat = rule[i].isfloat;
198 c->tags[tsel] = tags[tsel];
204 arrange = arrange == dofloat ? dotile : dofloat;