Xinqi Bao's Git
1 /* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * See LICENSE file for license details.
12 if((clients
&& clients
->isfloat
) || arrange
== dofloat
)
13 return clients
; /* don't touch floating order */
14 for(min
= c
= clients
; c
; c
= c
->next
)
15 if(c
->weight
< min
->weight
)
21 nexttiled(Client
*c
) {
22 for(c
= getnext(c
); c
&& c
->isfloat
; c
= getnext(c
->next
));
28 Client
*c
, *newclients
, *tail
;
30 newclients
= tail
= NULL
;
31 while((c
= minclient())) {
39 tail
= newclients
= c
;
45 togglemax(Client
*c
) {
48 if((c
->ismax
= !c
->ismax
)) {
49 c
->rx
= c
->x
; c
->x
= sx
;
50 c
->ry
= c
->y
; c
->y
= bh
;
51 c
->rw
= c
->w
; c
->w
= sw
- 2 * BORDERPX
;
52 c
->rh
= c
->h
; c
->h
= sh
- bh
- 2 * BORDERPX
;
60 resize(c
, True
, TopLeft
);
61 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
66 void (*arrange
)(void) = DEFMODE
;
71 c
->prev
->next
= c
->next
;
73 c
->next
->prev
= c
->prev
;
76 c
->next
= c
->prev
= NULL
;
83 for(c
= clients
; c
; c
= c
->next
) {
85 resize(c
, True
, TopLeft
);
90 if(!sel
|| !isvisible(sel
)) {
91 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
99 unsigned int i
, n
, mpx
, stackw
, stackh
, th
;
102 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
104 mpx
= (sw
* master
) / 1000;
111 for(i
= 0, c
= clients
; c
; c
= c
->next
)
114 resize(c
, True
, TopLeft
);
120 if(n
== 1) { /* only 1 window */
121 c
->w
= sw
- 2 * BORDERPX
;
122 c
->h
= sh
- 2 * BORDERPX
- bh
;
124 else if(i
== 0) { /* master window */
125 c
->w
= mpx
- 2 * BORDERPX
;
126 c
->h
= sh
- bh
- 2 * BORDERPX
;
128 else { /* tile window */
130 c
->w
= stackw
- 2 * BORDERPX
;
132 c
->y
= sy
+ (i
- 1) * th
+ bh
;
134 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
136 c
->h
= th
- 2 * BORDERPX
;
138 else /* fallback if th < bh */
139 c
->h
= stackh
- 2 * BORDERPX
;
141 resize(c
, False
, TopLeft
);
147 if(!sel
|| !isvisible(sel
)) {
148 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
155 focusnext(Arg
*arg
) {
160 if(!(c
= getnext(sel
->next
)))
161 c
= getnext(clients
);
169 focusprev(Arg
*arg
) {
174 if(!(c
= getprev(sel
->prev
))) {
175 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
185 isvisible(Client
*c
) {
188 for(i
= 0; i
< ntags
; i
++)
189 if(c
->tags
[i
] && seltag
[i
])
195 resizecol(Arg
*arg
) {
199 for(n
= 0, c
= clients
; c
; c
= c
->next
)
200 if(isvisible(c
) && !c
->isfloat
)
202 if(!sel
|| sel
->isfloat
|| n
< 2 || (arrange
== dofloat
))
204 if(sel
== getnext(clients
)) {
205 if(master
+ arg
->i
> 950 || master
+ arg
->i
< 50)
210 if(master
- arg
->i
> 950 || master
- arg
->i
< 50)
226 if(sel
->isfloat
|| arrange
== dofloat
) {
227 XRaiseWindow(dpy
, sel
->win
);
228 XRaiseWindow(dpy
, sel
->twin
);
230 if(arrange
!= dofloat
) {
232 XLowerWindow(dpy
, sel
->twin
);
233 XLowerWindow(dpy
, sel
->win
);
235 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
238 XLowerWindow(dpy
, c
->twin
);
239 XLowerWindow(dpy
, c
->win
);
244 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
248 togglemode(Arg
*arg
) {
249 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
257 toggleview(Arg
*arg
) {
260 seltag
[arg
->i
] = !seltag
[arg
->i
];
261 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
263 seltag
[arg
->i
] = True
; /* cannot toggle last view */
272 for(i
= 0; i
< ntags
; i
++)
274 seltag
[arg
->i
] = True
;
283 for(i
= 0; i
< ntags
; i
++)
296 if(sel
->isfloat
|| (arrange
== dofloat
)) {
300 for(n
= 0, c
= clients
; c
; c
= c
->next
)
301 if(isvisible(c
) && !c
->isfloat
)
303 if(n
< 2 || (arrange
== dofloat
))
305 if((c
= sel
) == nexttiled(clients
))
306 if(!(c
= nexttiled(c
->next
)))