Xinqi Bao's Git
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
);
152 if(!(c
= getnext(clients
, arg
->i
)))
155 for(i
= 0; i
< TLast
; i
++)
157 c
->tags
[tsel
] = tags
[tsel
];
170 for(i
= 0; i
< TLast
; i
++)
179 static unsigned int len
= rule
? sizeof(rule
) / sizeof(rule
[0]) : 0;
183 Bool matched
= False
;
187 c
->tags
[tsel
] = tags
[tsel
];
191 if(XGetClassHint(dpy
, c
->win
, &ch
)) {
192 snprintf(classinst
, sizeof(classinst
), "%s:%s",
193 ch
.res_class
? ch
.res_class
: "",
194 ch
.res_name
? ch
.res_name
: "");
195 for(i
= 0; !matched
&& i
< len
; i
++) {
196 if(!regcomp(®ex
, rule
[i
].pattern
, 0)) {
197 if(!regexec(®ex
, classinst
, 1, &tmp
, 0)) {
198 for(j
= 0; j
< TLast
; j
++) {
201 c
->tags
[j
] = rule
[i
].tags
[j
];
203 c
->isfloat
= rule
[i
].isfloat
;
214 c
->tags
[tsel
] = tags
[tsel
];
220 arrange
= arrange
== dofloat
? dotile
: dofloat
;