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>
15 const char *clpattern
;
30 static RReg
*rreg
= NULL
;
31 static unsigned int len
= 0;
33 void (*arrange
)(Arg
*) = DEFMODE
;
43 sel
->tags
[arg
->i
] = True
;
52 for(c
= clients
; c
; c
= c
->next
) {
55 resize(c
, True
, TopLeft
);
60 if((sel
= getnext(clients
))) {
65 XSetInputFocus(dpy
, root
, RevertToPointerRoot
, CurrentTime
);
76 for(n
= 0, c
= clients
; c
; c
= c
->next
)
77 if(c
->tags
[tsel
] && !c
->isfloat
)
81 h
= (sh
- bh
) / (n
- 1);
85 for(i
= 0, c
= clients
; c
; c
= c
->next
) {
90 resize(c
, True
, TopLeft
);
107 c
->y
= sy
+ (i
- 1) * h
+ bh
;
110 c
->h
= sh
- c
->y
- 2;
114 else { /* fallback if h < bh */
120 resize(c
, False
, TopLeft
);
126 if((sel
= getnext(clients
))) {
131 XSetInputFocus(dpy
, root
, RevertToPointerRoot
, CurrentTime
);
138 for(; c
&& !c
->tags
[tsel
]; c
= c
->next
);
145 for(; c
&& !c
->tags
[tsel
]; c
= c
->prev
);
157 len
= sizeof(rule
) / sizeof(rule
[0]);
158 rreg
= emallocz(len
* sizeof(RReg
));
160 for(i
= 0; i
< len
; i
++) {
161 if(rule
[i
].clpattern
) {
162 reg
= emallocz(sizeof(regex_t
));
163 if(regcomp(reg
, rule
[i
].clpattern
, 0))
166 rreg
[i
].clregex
= reg
;
168 if(rule
[i
].tpattern
) {
169 reg
= emallocz(sizeof(regex_t
));
170 if(regcomp(reg
, rule
[i
].tpattern
, 0))
173 rreg
[i
].tregex
= reg
;
186 for(i
= 0; i
< ntags
; i
++)
187 sel
->tags
[i
] = False
;
197 Bool matched
= False
;
200 if(XGetClassHint(dpy
, c
->win
, &ch
)) {
201 snprintf(classinst
, sizeof(classinst
), "%s:%s",
202 ch
.res_class
? ch
.res_class
: "",
203 ch
.res_name
? ch
.res_name
: "");
204 for(i
= 0; !matched
&& i
< len
; i
++)
205 if(rreg
[i
].clregex
&& !regexec(rreg
[i
].clregex
, classinst
, 1, &tmp
, 0)) {
206 c
->isfloat
= rule
[i
].isfloat
;
207 for(j
= 0; rreg
[i
].tregex
&& j
< ntags
; j
++) {
208 if(!regexec(rreg
[i
].tregex
, tags
[j
], 1, &tmp
, 0)) {
220 c
->tags
[tsel
] = True
;
226 arrange
= arrange
== dofloat
? dotile
: dofloat
;
241 arg
->i
= (tsel
< ntags
-1) ? tsel
+1 : 0;
248 arg
->i
= (tsel
> 0) ? tsel
-1 : ntags
-1;