Xinqi Bao's Git
bc731c9ab891f9103c37f77585606c40d6c7c9bd
1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
2 * See LICENSE file for license details.
10 #include <X11/Xutil.h>
14 const char *clpattern
;
29 static RReg
*rreg
= NULL
;
30 static unsigned int len
= 0;
36 for(; c
&& !isvisible(c
); c
= c
->next
);
42 for(; c
&& !isvisible(c
); c
= c
->prev
);
53 len
= sizeof rule
/ sizeof rule
[0];
54 rreg
= emallocz(len
* sizeof(RReg
));
55 for(i
= 0; i
< len
; i
++) {
56 if(rule
[i
].clpattern
) {
57 reg
= emallocz(sizeof(regex_t
));
58 if(regcomp(reg
, rule
[i
].clpattern
, REG_EXTENDED
))
61 rreg
[i
].clregex
= reg
;
63 if(rule
[i
].tpattern
) {
64 reg
= emallocz(sizeof(regex_t
));
65 if(regcomp(reg
, rule
[i
].tpattern
, REG_EXTENDED
))
74 settags(Client
*c
, Client
*trans
) {
78 Bool matched
= trans
!= NULL
;
79 XClassHint ch
= { 0 };
82 for(i
= 0; i
< ntags
; i
++)
83 c
->tags
[i
] = trans
->tags
[i
];
86 XGetClassHint(dpy
, c
->win
, &ch
);
87 snprintf(prop
, sizeof prop
, "%s:%s:%s",
88 ch
.res_class
? ch
.res_class
: "",
89 ch
.res_name
? ch
.res_name
: "", c
->name
);
90 for(i
= 0; i
< len
; i
++)
91 if(rreg
[i
].clregex
&& !regexec(rreg
[i
].clregex
, prop
, 1, &tmp
, 0)) {
92 c
->isfloat
= rule
[i
].isfloat
;
93 for(j
= 0; rreg
[i
].tregex
&& j
< ntags
; j
++) {
94 if(!regexec(rreg
[i
].tregex
, tags
[j
], 1, &tmp
, 0)) {
106 for(i
= 0; i
< ntags
; i
++)
107 c
->tags
[i
] = seltag
[i
];
116 for(i
= 0; i
< ntags
; i
++)
117 sel
->tags
[i
] = (arg
->i
== -1) ? True
: False
;
118 if(arg
->i
>= 0 && arg
->i
< ntags
)
119 sel
->tags
[arg
->i
] = True
;
124 toggletag(Arg
*arg
) {
129 sel
->tags
[arg
->i
] = !sel
->tags
[arg
->i
];
130 for(i
= 0; i
< ntags
&& !sel
->tags
[i
]; i
++);
132 sel
->tags
[arg
->i
] = True
;