Xinqi Bao's Git
90080fb1f5bbdef26cf101ff5074ab28b6f46066
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
13 if((clients
&& clients
->isfloat
) || arrange
== dofloat
)
14 return clients
; /* don't touch floating order */
15 for(min
= c
= clients
; c
; c
= c
->next
)
16 if(c
->weight
< min
->weight
)
22 nexttiled(Client
*c
) {
23 for(c
= getnext(c
); c
&& c
->isfloat
; c
= getnext(c
->next
));
29 Client
*c
, *newclients
, *tail
;
31 newclients
= tail
= NULL
;
32 while((c
= minclient())) {
40 tail
= newclients
= c
;
49 if((c
->ismax
= !c
->ismax
)) {
50 c
->rx
= c
->x
; c
->x
= sx
;
51 c
->ry
= c
->y
; c
->y
= bh
;
52 c
->rw
= c
->w
; c
->w
= sw
- 2 * BORDERPX
;
53 c
->rh
= c
->h
; c
->h
= sh
- bh
- 2 * BORDERPX
;
61 resize(c
, True
, TopLeft
);
62 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
67 void (*arrange
)(Arg
*) = DEFMODE
;
68 Bool isvertical
= VERTICALSTACK
;
69 StackPos stackpos
= STACKPOS
;
74 c
->prev
->next
= c
->next
;
76 c
->next
->prev
= c
->prev
;
79 c
->next
= c
->prev
= NULL
;
86 for(c
= clients
; c
; c
= c
->next
) {
88 resize(c
, True
, TopLeft
);
93 if(!sel
|| !isvisible(sel
)) {
94 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
100 /* This algorithm is based on a (M)aster area and a (S)tacking area.
101 * It supports following arrangements:
111 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
115 if(stackpos
== StackBottom
) {
118 h
= (sh
- bh
) / (n
- 1);
125 h
= (sh
- bh
) / (n
- 1);
130 else { /* horizontal stack */
134 for(i
= 0, c
= clients
; c
; c
= c
->next
) {
137 resize(c
, True
, TopLeft
);
144 c
->w
= sw
- 2 * BORDERPX
;
145 c
->h
= sh
- 2 * BORDERPX
- bh
;
150 c
->w
= master
- 2 * BORDERPX
;
151 c
->h
= sh
- 2 * BORDERPX
- bh
;
155 c
->y
= sy
+ (i
- 1) * h
+ bh
;
156 c
->w
= w
- 2 * BORDERPX
;
158 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
160 c
->h
= h
- 2 * BORDERPX
;
162 else { /* fallback if h < bh */
165 c
->w
= w
- 2 * BORDERPX
;
166 c
->h
= sh
- 2 * BORDERPX
- bh
;
168 resize(c
, False
, TopLeft
);
174 if(!sel
|| !isvisible(sel
)) {
175 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
182 focusnext(Arg
*arg
) {
188 if(!(c
= getnext(sel
->next
)))
189 c
= getnext(clients
);
197 focusprev(Arg
*arg
) {
203 if(!(c
= getprev(sel
->prev
))) {
204 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
214 isvisible(Client
*c
) {
217 for(i
= 0; i
< ntags
; i
++)
218 if(c
->tags
[i
] && seltag
[i
])
224 resizecol(Arg
*arg
) {
228 for(n
= 0, c
= clients
; c
; c
= c
->next
)
229 if(isvisible(c
) && !c
->isfloat
)
231 if(!sel
|| sel
->isfloat
|| n
< 2 || (arrange
== dofloat
))
234 if(sel
== getnext(clients
)) {
235 if(master
+ arg
->i
> sw
- 100 || master
+ arg
->i
< 100)
240 if(master
- arg
->i
> sw
- 100 || master
- arg
->i
< 100)
256 if(sel
->isfloat
|| arrange
== dofloat
) {
257 XRaiseWindow(dpy
, sel
->win
);
258 XRaiseWindow(dpy
, sel
->twin
);
260 if(arrange
!= dofloat
)
261 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
262 XLowerWindow(dpy
, c
->twin
);
263 XLowerWindow(dpy
, c
->win
);
267 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
271 togglemode(Arg
*arg
) {
272 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
280 toggleview(Arg
*arg
) {
283 seltag
[arg
->i
] = !seltag
[arg
->i
];
284 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
286 seltag
[arg
->i
] = True
; /* cannot toggle last view */
295 for(i
= 0; i
< ntags
; i
++)
297 seltag
[arg
->i
] = True
;
306 for(i
= 0; i
< ntags
; i
++)
320 if(sel
->isfloat
|| (arrange
== dofloat
)) {
325 for(n
= 0, c
= clients
; c
; c
= c
->next
)
326 if(isvisible(c
) && !c
->isfloat
)
328 if(n
< 2 || (arrange
== dofloat
))
331 if((c
= sel
) == nexttiled(clients
))
332 if(!(c
= nexttiled(c
->next
)))