Xinqi Bao's Git
1bce54a0633155aea7f52e7f79a046704efd4720
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
15 if((clients
&& clients
->isfloat
) || arrange
== dofloat
)
16 return clients
; /* don't touch floating order */
17 for(min
= c
= clients
; c
; c
= c
->next
)
18 if(c
->weight
< min
->weight
)
24 nexttiled(Client
*c
) {
25 for(c
= getnext(c
); c
&& c
->isfloat
; c
= getnext(c
->next
));
31 Client
*c
, *newclients
, *tail
;
33 newclients
= tail
= NULL
;
34 while((c
= minclient())) {
42 tail
= newclients
= c
;
51 if((c
->ismax
= !c
->ismax
)) {
52 c
->rx
= c
->x
; c
->x
= sx
;
53 c
->ry
= c
->y
; c
->y
= bh
;
54 c
->rw
= c
->w
; c
->w
= sw
- 2 * BORDERPX
;
55 c
->rh
= c
->h
; c
->h
= sh
- bh
- 2 * BORDERPX
;
63 resize(c
, True
, TopLeft
);
64 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
69 void (*arrange
)(Arg
*) = DEFMODE
;
70 StackPos stackpos
= STACKPOS
;
75 c
->prev
->next
= c
->next
;
77 c
->next
->prev
= c
->prev
;
80 c
->next
= c
->prev
= NULL
;
87 for(c
= clients
; c
; c
= c
->next
) {
89 resize(c
, True
, TopLeft
);
94 if(!sel
|| !isvisible(sel
)) {
95 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
101 /* This algorithm is based on a (M)aster area and a (S)tacking area.
102 * It supports following arrangements:
108 int i
, n
, stackw
, stackh
, tw
, th
;
111 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
114 if(stackpos
== StackBottom
) {
116 stackh
= sh
- bh
- master
;
119 stackw
= sw
- master
;
125 th
= stackh
/ (n
- 1);
129 for(i
= 0, c
= clients
; c
; c
= c
->next
) {
132 resize(c
, True
, TopLeft
);
138 if(n
== 1) { /* only 1 window */
139 c
->w
= sw
- 2 * BORDERPX
;
140 c
->h
= sh
- 2 * BORDERPX
- bh
;
142 else if(i
== 0) { /* master window */
143 if(stackpos
== StackLeft
)
148 c
->w
= master
- 2 * BORDERPX
;
149 c
->h
= sh
- bh
- 2 * BORDERPX
;
152 c
->w
= sw
- 2 * BORDERPX
;
153 c
->h
= master
- 2 * BORDERPX
;
157 else { /* tile window */
158 if(stackpos
== StackRight
)
164 c
->y
= sy
+ (i
- 1) * th
+ bh
;
166 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
169 c
->y
= sy
+ master
+ (i
- 1) * th
+ bh
;
171 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
174 c
->w
= tw
- 2 * BORDERPX
;
175 c
->h
= th
- 2 * BORDERPX
;
177 else { /* fallback if th < bh */
178 if(stackpos
== StackBottom
)
180 c
->w
= stackw
- 2 * BORDERPX
;
181 c
->h
= stackh
- 2 * BORDERPX
;
184 resize(c
, False
, TopLeft
);
190 if(!sel
|| !isvisible(sel
)) {
191 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
198 focusnext(Arg
*arg
) {
204 if(!(c
= getnext(sel
->next
)))
205 c
= getnext(clients
);
213 focusprev(Arg
*arg
) {
219 if(!(c
= getprev(sel
->prev
))) {
220 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
230 isvisible(Client
*c
) {
233 for(i
= 0; i
< ntags
; i
++)
234 if(c
->tags
[i
] && seltag
[i
])
240 resizecol(Arg
*arg
) {
245 for(n
= 0, c
= clients
; c
; c
= c
->next
)
246 if(isvisible(c
) && !c
->isfloat
)
248 if(!sel
|| sel
->isfloat
|| n
< 2 || (arrange
== dofloat
))
251 s
= stackpos
== StackBottom
? sh
- bh
: sw
;
252 if(sel
== getnext(clients
)) {
253 if(master
+ arg
->i
> s
- MINDIM
|| master
+ arg
->i
< MINDIM
)
258 if(master
- arg
->i
> s
- MINDIM
|| master
- arg
->i
< MINDIM
)
274 if(sel
->isfloat
|| arrange
== dofloat
) {
275 XRaiseWindow(dpy
, sel
->win
);
276 XRaiseWindow(dpy
, sel
->twin
);
278 if(arrange
!= dofloat
) {
280 XLowerWindow(dpy
, sel
->twin
);
281 XLowerWindow(dpy
, sel
->win
);
283 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
286 XLowerWindow(dpy
, c
->twin
);
287 XLowerWindow(dpy
, c
->win
);
292 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
296 togglemode(Arg
*arg
) {
297 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
305 toggleview(Arg
*arg
) {
308 seltag
[arg
->i
] = !seltag
[arg
->i
];
309 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
311 seltag
[arg
->i
] = True
; /* cannot toggle last view */
317 togglestackpos(Arg
*arg
) {
318 if(arrange
== dofloat
)
320 if(stackpos
== StackBottom
)
323 stackpos
= StackBottom
;
324 master
= ((stackpos
== StackBottom
? sh
- bh
: sw
) * MASTER
) / 100;
332 for(i
= 0; i
< ntags
; i
++)
334 seltag
[arg
->i
] = True
;
343 for(i
= 0; i
< ntags
; i
++)
359 if(sel
->isfloat
|| (arrange
== dofloat
)) {
364 for(n
= 0, c
= clients
; c
; c
= c
->next
)
365 if(isvisible(c
) && !c
->isfloat
)
367 if(n
< 2 || (arrange
== dofloat
))
370 if((c
= sel
) == nexttiled(clients
))
371 if(!(c
= nexttiled(c
->next
)))