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
;
111 else { /* fallback if h < bh */
117 resize(c
, False
, TopLeft
);
123 if((sel
= getnext(clients
))) {
128 XSetInputFocus(dpy
, root
, RevertToPointerRoot
, CurrentTime
);
135 for(; c
&& !c
->tags
[tsel
]; c
= c
->next
);
142 for(; c
&& !c
->tags
[tsel
]; c
= c
->prev
);
154 len
= sizeof(rule
) / sizeof(rule
[0]);
155 rreg
= emallocz(len
* sizeof(RReg
));
157 for(i
= 0; i
< len
; i
++) {
158 if(rule
[i
].clpattern
) {
159 reg
= emallocz(sizeof(regex_t
));
160 if(regcomp(reg
, rule
[i
].clpattern
, 0))
163 rreg
[i
].clregex
= reg
;
165 if(rule
[i
].tpattern
) {
166 reg
= emallocz(sizeof(regex_t
));
167 if(regcomp(reg
, rule
[i
].tpattern
, 0))
170 rreg
[i
].tregex
= reg
;
183 for(i
= 0; i
< ntags
; i
++)
184 sel
->tags
[i
] = False
;
194 Bool matched
= False
;
197 if(XGetClassHint(dpy
, c
->win
, &ch
)) {
198 snprintf(classinst
, sizeof(classinst
), "%s:%s",
199 ch
.res_class
? ch
.res_class
: "",
200 ch
.res_name
? ch
.res_name
: "");
201 for(i
= 0; !matched
&& i
< len
; i
++)
202 if(rreg
[i
].clregex
&& !regexec(rreg
[i
].clregex
, classinst
, 1, &tmp
, 0)) {
203 c
->isfloat
= rule
[i
].isfloat
;
204 for(j
= 0; rreg
[i
].tregex
&& j
< ntags
; j
++) {
205 if(!regexec(rreg
[i
].tregex
, tags
[j
], 1, &tmp
, 0)) {
217 c
->tags
[tsel
] = True
;
223 arrange
= arrange
== dofloat
? dotile
: dofloat
;
238 arg
->i
= (tsel
< ntags
-1) ? tsel
+1 : 0;
245 arg
->i
= (tsel
> 0) ? tsel
-1 : ntags
-1;