Xinqi Bao's Git
ddffafa16e5a31d827a7e999a7692cc9edbe4c71
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;
36 /* asserts sel != NULL */
49 for(; c
&& !isvisible(c
); c
= c
->next
);
56 for(; c
&& !isvisible(c
); c
= c
->prev
);
68 len
= sizeof(rule
) / sizeof(rule
[0]);
69 rreg
= emallocz(len
* sizeof(RReg
));
71 for(i
= 0; i
< len
; i
++) {
72 if(rule
[i
].clpattern
) {
73 reg
= emallocz(sizeof(regex_t
));
74 if(regcomp(reg
, rule
[i
].clpattern
, 0))
77 rreg
[i
].clregex
= reg
;
79 if(rule
[i
].tpattern
) {
80 reg
= emallocz(sizeof(regex_t
));
81 if(regcomp(reg
, rule
[i
].tpattern
, 0))
98 if(XGetClassHint(dpy
, c
->win
, &ch
)) {
99 snprintf(prop
, sizeof(prop
), "%s:%s:%s",
100 ch
.res_class
? ch
.res_class
: "",
101 ch
.res_name
? ch
.res_name
: "", c
->name
);
102 for(i
= 0; !matched
&& i
< len
; i
++)
103 if(rreg
[i
].clregex
&& !regexec(rreg
[i
].clregex
, prop
, 1, &tmp
, 0)) {
104 c
->isfloat
= rule
[i
].isfloat
;
105 for(j
= 0; rreg
[i
].tregex
&& j
< ntags
; j
++) {
106 if(!regexec(rreg
[i
].tregex
, tags
[j
], 1, &tmp
, 0)) {
118 for(i
= 0; i
< ntags
; i
++)
119 c
->tags
[i
] = seltag
[i
];
120 for(i
= 0; i
< ntags
&& !c
->tags
[i
]; i
++);
132 for(i
= 0; i
< ntags
; i
++)
133 sel
->tags
[i
] = False
;
134 sel
->tags
[arg
->i
] = True
;
146 sel
->tags
[arg
->i
] = !sel
->tags
[arg
->i
];
147 for(i
= 0; i
< ntags
&& !sel
->tags
[i
]; i
++);
149 sel
->tags
[arg
->i
] = True
;