Xinqi Bao's Git
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 StackPos stackpos
= STACKPOS
;
73 c
->prev
->next
= c
->next
;
75 c
->next
->prev
= c
->prev
;
78 c
->next
= c
->prev
= NULL
;
85 for(c
= clients
; c
; c
= c
->next
) {
87 resize(c
, True
, TopLeft
);
92 if(!sel
|| !isvisible(sel
)) {
93 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
99 /* This algorithm is based on a (M)aster area and a (S)tacking area.
100 * It supports following arrangements:
106 int i
, n
, stackw
, stackh
, tw
, th
;
109 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
112 if(stackpos
== StackBottom
) {
114 stackh
= sh
- bh
- master
;
117 stackw
= sw
- master
;
123 th
= stackh
/ (n
- 1);
127 for(i
= 0, c
= clients
; c
; c
= c
->next
) {
130 resize(c
, True
, TopLeft
);
134 if(n
== 1) { /* only 1 window */
137 c
->w
= sw
- 2 * BORDERPX
;
138 c
->h
= sh
- 2 * BORDERPX
- bh
;
140 else if(i
== 0) { /* master window */
145 c
->w
= master
- 2 * BORDERPX
;
146 c
->h
= sh
- bh
- 2 * BORDERPX
;
151 c
->w
= sw
- 2 * BORDERPX
;
152 c
->h
= master
- 2 * BORDERPX
;
157 c
->w
= master
- 2 * BORDERPX
;
158 c
->h
= sh
- bh
- 2 * BORDERPX
;
164 c
->w
= tw
- 2 * BORDERPX
;
165 c
->h
= th
- 2 * BORDERPX
;
169 c
->y
= sy
+ (i
- 1) * th
+ bh
;
171 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
175 c
->y
= sy
+ master
+ (i
- 1) * th
+ bh
;
177 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
181 c
->y
= sy
+ (i
- 1) * th
+ bh
;
183 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
187 else { /* fallback if th < bh */
188 c
->w
= stackw
- 2 * BORDERPX
;
189 c
->h
= stackh
- 2 * BORDERPX
;
197 c
->y
= sy
+ master
+ bh
;
205 resize(c
, False
, TopLeft
);
211 if(!sel
|| !isvisible(sel
)) {
212 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
219 focusnext(Arg
*arg
) {
225 if(!(c
= getnext(sel
->next
)))
226 c
= getnext(clients
);
234 focusprev(Arg
*arg
) {
240 if(!(c
= getprev(sel
->prev
))) {
241 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
251 isvisible(Client
*c
) {
254 for(i
= 0; i
< ntags
; i
++)
255 if(c
->tags
[i
] && seltag
[i
])
261 resizecol(Arg
*arg
) {
266 for(n
= 0, c
= clients
; c
; c
= c
->next
)
267 if(isvisible(c
) && !c
->isfloat
)
269 if(!sel
|| sel
->isfloat
|| n
< 2 || (arrange
== dofloat
))
272 s
= stackpos
== StackBottom
? sh
- bh
: sw
;
273 if(sel
== getnext(clients
)) {
274 if(master
+ arg
->i
> s
- MINW
|| master
+ arg
->i
< MINW
)
279 if(master
- arg
->i
> s
- MINW
|| master
- arg
->i
< MINW
)
295 if(sel
->isfloat
|| arrange
== dofloat
) {
296 XRaiseWindow(dpy
, sel
->win
);
297 XRaiseWindow(dpy
, sel
->twin
);
299 if(arrange
!= dofloat
) {
301 XLowerWindow(dpy
, sel
->twin
);
302 XLowerWindow(dpy
, sel
->win
);
304 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
307 XLowerWindow(dpy
, c
->twin
);
308 XLowerWindow(dpy
, c
->win
);
313 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
317 togglemode(Arg
*arg
) {
318 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
326 toggleview(Arg
*arg
) {
329 seltag
[arg
->i
] = !seltag
[arg
->i
];
330 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
332 seltag
[arg
->i
] = True
; /* cannot toggle last view */
338 togglestackpos(Arg
*arg
) {
339 if(arrange
== dofloat
)
341 if(stackpos
== StackBottom
)
344 stackpos
= StackBottom
;
345 master
= ((stackpos
== StackBottom
? sh
- bh
: sw
) * MASTER
) / 100;
353 for(i
= 0; i
< ntags
; i
++)
355 seltag
[arg
->i
] = True
;
364 for(i
= 0; i
< ntags
; i
++)
380 if(sel
->isfloat
|| (arrange
== dofloat
)) {
385 for(n
= 0, c
= clients
; c
; c
= c
->next
)
386 if(isvisible(c
) && !c
->isfloat
)
388 if(n
< 2 || (arrange
== dofloat
))
391 if((c
= sel
) == nexttiled(clients
))
392 if(!(c
= nexttiled(c
->next
)))