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
);
75 for(n
= 0, c
= clients
; c
; c
= c
->next
)
76 if(isvisible(c
) && !c
->isfloat
)
80 h
= (sh
- bh
) / (n
- 1);
84 for(i
= 0, c
= clients
; c
; c
= c
->next
) {
88 resize(c
, True
, TopLeft
);
105 c
->y
= sy
+ (i
- 1) * h
+ bh
;
108 c
->h
= sh
- c
->y
- 2;
112 else { /* fallback if h < bh */
118 resize(c
, False
, TopLeft
);
124 if((sel
= getnext(clients
)))
127 XSetInputFocus(dpy
, root
, RevertToPointerRoot
, CurrentTime
);
134 for(; c
&& !isvisible(c
); c
= c
->next
);
141 for(; c
&& !isvisible(c
); c
= c
->prev
);
153 len
= sizeof(rule
) / sizeof(rule
[0]);
154 rreg
= emallocz(len
* sizeof(RReg
));
156 for(i
= 0; i
< len
; i
++) {
157 if(rule
[i
].clpattern
) {
158 reg
= emallocz(sizeof(regex_t
));
159 if(regcomp(reg
, rule
[i
].clpattern
, 0))
162 rreg
[i
].clregex
= reg
;
164 if(rule
[i
].tpattern
) {
165 reg
= emallocz(sizeof(regex_t
));
166 if(regcomp(reg
, rule
[i
].tpattern
, 0))
169 rreg
[i
].tregex
= reg
;
179 for(i
= 0; i
< ntags
; i
++)
180 if(c
->tags
[i
] && seltag
[i
])
193 for(i
= 0; i
< ntags
; i
++)
194 sel
->tags
[i
] = False
;
201 static unsigned int nwins
= 0;
202 static Window
*wins
= NULL
;
203 unsigned int f
, fi
, m
, mi
, n
;
207 for(f
= 0, m
= 0, c
= clients
; c
; c
= c
->next
)
209 if(c
->isfloat
|| arrange
== dofloat
)
218 wins
= erealloc(wins
, nwins
* sizeof(Window
));
223 if(sel
->isfloat
|| arrange
== dofloat
) {
224 wins
[fi
++] = sel
->title
;
225 wins
[fi
++] = sel
->win
;
228 wins
[mi
++] = sel
->title
;
229 wins
[mi
++] = sel
->win
;
231 for(c
= clients
; c
; c
= c
->next
)
232 if(isvisible(c
) && c
!= sel
) {
233 if(c
->isfloat
|| arrange
== dofloat
) {
234 wins
[fi
++] = c
->title
;
238 wins
[mi
++] = c
->title
;
242 XRestackWindows(dpy
, wins
, n
);
245 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
254 Bool matched
= False
;
257 if(XGetClassHint(dpy
, c
->win
, &ch
)) {
258 snprintf(classinst
, sizeof(classinst
), "%s:%s",
259 ch
.res_class
? ch
.res_class
: "",
260 ch
.res_name
? ch
.res_name
: "");
261 for(i
= 0; !matched
&& i
< len
; i
++)
262 if(rreg
[i
].clregex
&& !regexec(rreg
[i
].clregex
, classinst
, 1, &tmp
, 0)) {
263 c
->isfloat
= rule
[i
].isfloat
;
264 for(j
= 0; rreg
[i
].tregex
&& j
< ntags
; j
++) {
265 if(!regexec(rreg
[i
].tregex
, tags
[j
], 1, &tmp
, 0)) {
277 for(i
= 0; i
< ntags
; i
++)
278 c
->tags
[i
] = seltag
[i
];
284 arrange
= arrange
== dofloat
? dotile
: dofloat
;
293 for(i
= 0; i
< ntags
; i
++)
295 seltag
[arg
->i
] = True
;
304 seltag
[arg
->i
] = !seltag
[arg
->i
];
305 for(i
= 0; !seltag
[i
] && i
< ntags
; i
++);
307 seltag
[arg
->i
] = True
; /* cannot toggle last view */