Xinqi Bao's Git
1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
2 * See LICENSE file for license details.
26 static Regs
*regs
= NULL
;
27 static unsigned int nrules
= 0;
38 nrules
= sizeof rule
/ sizeof rule
[0];
39 regs
= emallocz(nrules
* sizeof(Regs
));
40 for(i
= 0; i
< nrules
; i
++) {
42 reg
= emallocz(sizeof(regex_t
));
43 if(regcomp(reg
, rule
[i
].prop
, REG_EXTENDED
))
46 regs
[i
].propregex
= reg
;
49 reg
= emallocz(sizeof(regex_t
));
50 if(regcomp(reg
, rule
[i
].tags
, REG_EXTENDED
))
53 regs
[i
].tagregex
= reg
;
59 isvisible(Client
*c
) {
62 for(i
= 0; i
< ntags
; i
++)
63 if(c
->tags
[i
] && seltag
[i
])
69 settags(Client
*c
, Client
*trans
) {
73 Bool matched
= trans
!= NULL
;
74 XClassHint ch
= { 0 };
77 for(i
= 0; i
< ntags
; i
++)
78 c
->tags
[i
] = trans
->tags
[i
];
80 XGetClassHint(dpy
, c
->win
, &ch
);
81 snprintf(prop
, sizeof prop
, "%s:%s:%s",
82 ch
.res_class
? ch
.res_class
: "",
83 ch
.res_name
? ch
.res_name
: "", c
->name
);
84 for(i
= 0; i
< nrules
; i
++)
85 if(regs
[i
].propregex
&& !regexec(regs
[i
].propregex
, prop
, 1, &tmp
, 0)) {
86 c
->isversatile
= rule
[i
].isversatile
;
87 for(j
= 0; regs
[i
].tagregex
&& j
< ntags
; j
++) {
88 if(!regexec(regs
[i
].tagregex
, tags
[j
], 1, &tmp
, 0)) {
100 for(i
= 0; i
< ntags
; i
++)
101 c
->tags
[i
] = seltag
[i
];
110 for(i
= 0; i
< ntags
; i
++)
111 sel
->tags
[i
] = (arg
.i
== -1) ? True
: False
;
112 if(arg
.i
>= 0 && arg
.i
< ntags
)
113 sel
->tags
[arg
.i
] = True
;
123 sel
->tags
[arg
.i
] = !sel
->tags
[arg
.i
];
124 for(i
= 0; i
< ntags
&& !sel
->tags
[i
]; i
++);
126 sel
->tags
[arg
.i
] = True
;
131 toggleview(Arg arg
) {
134 seltag
[arg
.i
] = !seltag
[arg
.i
];
135 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
137 seltag
[arg
.i
] = True
; /* cannot toggle last view */
145 for(i
= 0; i
< ntags
; i
++)
146 seltag
[i
] = (arg
.i
== -1) ? True
: False
;
147 if(arg
.i
>= 0 && arg
.i
< ntags
)
148 seltag
[arg
.i
] = True
;