Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
10 static unsigned int nlayouts
= 0;
11 static unsigned int masterw
= MASTERWIDTH
;
12 static unsigned int nmaster
= NMASTER
;
16 unsigned int i
, n
, nx
, ny
, nw
, nh
, mw
, mh
, tw
, th
;
19 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
22 mh
= (n
> nmaster
) ? wah
/ nmaster
: wah
/ (n
> 0 ? n
: 1);
23 mw
= (n
> nmaster
) ? (waw
* masterw
) / 1000 : waw
;
24 th
= (n
> nmaster
) ? wah
/ (n
- nmaster
) : 0;
27 for(i
= 0, c
= clients
; c
; c
= c
->next
)
37 nw
= mw
- 2 * c
->border
;
39 if(i
+ 1 == (n
< nmaster
? n
: nmaster
)) /* remainder */
43 else { /* tile window */
45 nw
= tw
- 2 * c
->border
;
46 if(th
> 2 * c
->border
) {
47 ny
+= (i
- nmaster
) * th
;
49 if(i
+ 1 == n
) /* remainder */
50 nh
= wah
- th
* (i
- nmaster
);
53 else /* fallback if th <= 2 * c->border */
54 nh
= wah
- 2 * c
->border
;
56 resize(c
, nx
, ny
, nw
, nh
, False
);
73 for(c
= clients
; c
; c
= c
->next
)
76 resize(c
, c
->x
, c
->y
, c
->w
, c
->h
, True
);
85 focusclient(const char *arg
) {
91 for(c
= sel
->prev
; c
&& !isvisible(c
); c
= c
->prev
);
93 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
94 for(; c
&& !isvisible(c
); c
= c
->prev
);
98 for(c
= sel
->next
; c
&& !isvisible(c
); c
= c
->next
);
100 for(c
= clients
; c
&& !isvisible(c
); c
= c
->next
);
109 incmasterw(const char *arg
) {
111 if(lt
->arrange
!= tile
)
114 masterw
= MASTERWIDTH
;
117 if(waw
* (masterw
+ i
) / 1000 >= waw
- 2 * BORDERPX
118 || waw
* (masterw
+ i
) / 1000 <= 2 * BORDERPX
)
126 incnmaster(const char *arg
) {
133 if((lt
->arrange
!= tile
) || (nmaster
+ i
< 1)
134 || (wah
/ (nmaster
+ i
) <= 2 * BORDERPX
))
149 nlayouts
= sizeof layout
/ sizeof layout
[0];
150 for(blw
= i
= 0; i
< nlayouts
; i
++) {
151 w
= textw(layout
[i
].symbol
);
158 nexttiled(Client
*c
) {
159 for(; c
&& (c
->isfloating
|| !isvisible(c
)); c
= c
->next
);
171 if(sel
->isfloating
|| lt
->arrange
== floating
)
172 XRaiseWindow(dpy
, sel
->win
);
173 if(lt
->arrange
!= floating
) {
175 XLowerWindow(dpy
, sel
->win
);
176 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
179 XLowerWindow(dpy
, c
->win
);
183 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
187 setlayout(const char *arg
) {
192 if(lt
== layout
+ nlayouts
)
197 if(i
< 0 || i
>= nlayouts
)
208 togglebar(const char *arg
) {
210 bpos
= (BARPOS
== BarOff
) ? BarTop
: BARPOS
;
218 togglemax(const char *arg
) {
221 if(!sel
|| (lt
->arrange
!= floating
&& !sel
->isfloating
) || sel
->isfixed
)
223 if((sel
->ismax
= !sel
->ismax
)) {
228 resize(sel
, wax
, way
, waw
- 2 * sel
->border
, wah
- 2 * sel
->border
, True
);
231 resize(sel
, sel
->rx
, sel
->ry
, sel
->rw
, sel
->rh
, True
);
233 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
237 zoom(const char *arg
) {
240 if(!sel
|| lt
->arrange
== floating
|| sel
->isfloating
)
242 if((c
= sel
) == nexttiled(clients
))
243 if(!(c
= nexttiled(c
->next
)))