Xinqi Bao's Git
0706c624a4d35edf601b09689913db32120ce492
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
;
18 XMoveWindow(dpy
, c
->win
, c
->x
+ 2 * sw
, c
->y
);
26 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
);
32 unsigned int i
, n
, nx
, ny
, nw
, nh
, mw
, mh
, tw
, th
;
35 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
38 mh
= (n
> nmaster
) ? wah
/ nmaster
: wah
/ (n
> 0 ? n
: 1);
39 mw
= (n
> nmaster
) ? (waw
* masterw
) / 1000 : waw
;
40 th
= (n
> nmaster
) ? wah
/ (n
- nmaster
) : 0;
43 for(i
= 0, c
= clients
; c
; c
= c
->next
)
53 nw
= mw
- 2 * c
->border
;
55 if(i
+ 1 == (n
< nmaster
? n
: nmaster
)) /* remainder */
59 else { /* tile window */
61 nw
= tw
- 2 * c
->border
;
62 if(th
> 2 * c
->border
) {
63 ny
+= (i
- nmaster
) * th
;
65 if(i
+ 1 == n
) /* remainder */
66 nh
= wah
- th
* (i
- nmaster
);
69 else /* fallback if th <= 2 * c->border */
70 nh
= wah
- 2 * c
->border
;
72 resize(c
, nx
, ny
, nw
, nh
, False
);
89 for(c
= clients
; c
; c
= c
->next
)
92 resize(c
, c
->x
, c
->y
, c
->w
, c
->h
, True
);
101 focusclient(const char *arg
) {
107 for(c
= sel
->prev
; c
&& !isvisible(c
); c
= c
->prev
);
109 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
110 for(; c
&& !isvisible(c
); c
= c
->prev
);
114 for(c
= sel
->next
; c
&& !isvisible(c
); c
= c
->next
);
116 for(c
= clients
; c
&& !isvisible(c
); c
= c
->next
);
125 incmasterw(const char *arg
) {
127 if(lt
->arrange
!= tile
)
130 masterw
= MASTERWIDTH
;
133 if(waw
* (masterw
+ i
) / 1000 >= waw
- 2 * BORDERPX
134 || waw
* (masterw
+ i
) / 1000 <= 2 * BORDERPX
)
142 incnmaster(const char *arg
) {
149 if((lt
->arrange
!= tile
) || (nmaster
+ i
< 1)
150 || (wah
/ (nmaster
+ i
) <= 2 * BORDERPX
))
165 nlayouts
= sizeof layout
/ sizeof layout
[0];
166 for(blw
= i
= 0; i
< nlayouts
; i
++) {
167 w
= textw(layout
[i
].symbol
);
174 nexttiled(Client
*c
) {
175 for(; c
&& (c
->isfloating
|| !isvisible(c
)); c
= c
->next
);
187 if(sel
->isfloating
|| lt
->arrange
== floating
)
188 XRaiseWindow(dpy
, sel
->win
);
189 if(lt
->arrange
!= floating
) {
191 XLowerWindow(dpy
, sel
->win
);
192 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
195 XLowerWindow(dpy
, c
->win
);
199 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
203 setlayout(const char *arg
) {
208 if(lt
== layout
+ nlayouts
)
213 if(i
< 0 || i
>= nlayouts
)
224 togglebar(const char *arg
) {
226 bpos
= (BARPOS
== BarOff
) ? BarTop
: BARPOS
;
234 togglemax(const char *arg
) {
237 if(!sel
|| (lt
->arrange
!= floating
&& !sel
->isfloating
) || sel
->isfixed
)
239 if((sel
->ismax
= !sel
->ismax
)) {
244 resize(sel
, wax
, way
, waw
- 2 * sel
->border
, wah
- 2 * sel
->border
, True
);
247 resize(sel
, sel
->rx
, sel
->ry
, sel
->rw
, sel
->rh
, True
);
249 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
253 zoom(const char *arg
) {
256 if(!sel
|| lt
->arrange
== floating
|| sel
->isfloating
)
258 if((c
= sel
) == nexttiled(clients
))
259 if(!(c
= nexttiled(c
->next
)))