Xinqi Bao's Git
b2ee32f06721a71c405d7f0914545738ba3a4073
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:
107 int i
, n
, stackw
, stackh
, tw
, th
;
110 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
113 if(stackpos
== StackBottom
) {
115 stackh
= sh
- bh
- master
;
118 stackw
= sw
- master
;
125 th
= stackh
/ (n
- 1);
132 tw
= stackw
/ (n
- 1);
137 for(i
= 0, c
= clients
; c
; c
= c
->next
) {
140 resize(c
, True
, TopLeft
);
144 if(n
== 1) { /* only 1 window */
147 c
->w
= sw
- 2 * BORDERPX
;
148 c
->h
= sh
- 2 * BORDERPX
- bh
;
150 else if(i
== 0) { /* master window */
152 if(stackpos
== StackLeft
)
156 c
->w
= master
- 2 * BORDERPX
;
157 c
->h
= sh
- 2 * BORDERPX
- bh
;
161 c
->h
= master
- 2 * BORDERPX
;
164 else if((isvertical
&& th
> bh
) || (!isvertical
&& tw
> MINW
)) {
168 c
->y
= sy
+ (i
- 1) * th
+ bh
;
171 if(stackpos
== StackRight
)
173 else if(stackpos
== StackBottom
)
175 c
->w
= tw
- 2 * BORDERPX
;
176 c
->h
= th
- 2 * BORDERPX
;
177 if(i
+ 1 == n
) { /* fixes for last tile to take up rest space */
179 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
181 if(stackpos
== StackLeft
)
182 c
->w
= master
- c
->x
- 2 * BORDERPX
;
184 c
->w
= sw
- c
->x
- 2 * BORDERPX
;
188 else { /* fallback if th < bh resp. tw < MINW */
191 if(stackpos
== StackRight
)
193 else if(stackpos
== StackBottom
)
195 c
->w
= stackw
- 2 * BORDERPX
;
196 c
->h
= stackh
- 2 * BORDERPX
;
198 resize(c
, False
, TopLeft
);
204 if(!sel
|| !isvisible(sel
)) {
205 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
212 focusnext(Arg
*arg
) {
218 if(!(c
= getnext(sel
->next
)))
219 c
= getnext(clients
);
227 focusprev(Arg
*arg
) {
233 if(!(c
= getprev(sel
->prev
))) {
234 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
244 isvisible(Client
*c
) {
247 for(i
= 0; i
< ntags
; i
++)
248 if(c
->tags
[i
] && seltag
[i
])
254 resizecol(Arg
*arg
) {
258 for(n
= 0, c
= clients
; c
; c
= c
->next
)
259 if(isvisible(c
) && !c
->isfloat
)
261 if(!sel
|| sel
->isfloat
|| n
< 2 || (arrange
== dofloat
))
264 if(sel
== getnext(clients
)) {
265 if(master
+ arg
->i
> sw
- MINW
|| master
+ arg
->i
< MINW
)
270 if(master
- arg
->i
> sw
- MINW
|| master
- arg
->i
< MINW
)
286 if(sel
->isfloat
|| arrange
== dofloat
) {
287 XRaiseWindow(dpy
, sel
->win
);
288 XRaiseWindow(dpy
, sel
->twin
);
290 if(arrange
!= dofloat
)
291 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
292 XLowerWindow(dpy
, c
->twin
);
293 XLowerWindow(dpy
, c
->win
);
297 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
301 togglemode(Arg
*arg
) {
302 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
310 toggleview(Arg
*arg
) {
313 seltag
[arg
->i
] = !seltag
[arg
->i
];
314 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
316 seltag
[arg
->i
] = True
; /* cannot toggle last view */
325 for(i
= 0; i
< ntags
; i
++)
327 seltag
[arg
->i
] = True
;
336 for(i
= 0; i
< ntags
; i
++)
350 if(sel
->isfloat
|| (arrange
== dofloat
)) {
355 for(n
= 0, c
= clients
; c
; c
= c
->next
)
356 if(isvisible(c
) && !c
->isfloat
)
358 if(n
< 2 || (arrange
== dofloat
))
361 if((c
= sel
) == nexttiled(clients
))
362 if(!(c
= nexttiled(c
->next
)))