Xinqi Bao's Git
b475d35d12e44e68ccc55d0e8a8320ca9859b55d
1 /* See LICENSE file for copyright and license details. */
11 static double hratio
= HRATIO
;
12 static double vratio
= VRATIO
;
13 static unsigned int nlayouts
= 0;
14 static unsigned int nmaster
= NMASTER
;
16 static double /* simple pow() */
17 spow(double x
, double y
)
28 double mscale
= 0, tscale
= 0, sum
= 0;
29 unsigned int i
, n
, nx
, ny
, nw
, nh
, mw
, tw
;
32 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
35 mw
= (n
<= nmaster
) ? waw
: waw
/ (1 + hratio
);
40 for(i
= 0; i
< n
; i
++)
41 sum
+= spow(vratio
, i
);
45 for(i
= 0; i
< nmaster
; i
++)
46 sum
+= spow(vratio
, i
);
48 for(sum
= 0, i
= 0; i
< (n
- nmaster
); i
++)
49 sum
+= spow(vratio
, i
);
55 for(i
= 0, c
= clients
; c
; c
= c
->next
)
61 if(i
< nmaster
) { /* master window */
62 nw
= mw
- 2 * c
->border
;
63 if(i
+ 1 == n
|| i
+ 1 == nmaster
)
64 nh
= (way
+ wah
) - ny
- (2 * c
->border
);
66 nh
= (mscale
* spow(vratio
, i
)) - (2 * c
->border
);
68 else { /* tile window */
73 nw
= tw
- 2 * c
->border
;
75 nh
= (way
+ wah
) - ny
- (2 * c
->border
);
77 nh
= (tscale
* spow(vratio
, i
- nmaster
)) - (2 * c
->border
);
83 resize(c
, nx
, ny
, nw
, nh
, False
);
96 incratio(const char *arg
, double *ratio
, double def
) {
99 if(lt
->arrange
!= tile
)
104 if(1 == sscanf(arg
, "%lf", &delta
)) {
105 if(delta
+ (*ratio
) < .1 || delta
+ (*ratio
) > 1.9)
119 for(c
= clients
; c
; c
= c
->next
)
122 resize(c
, c
->x
, c
->y
, c
->w
, c
->h
, True
);
131 focusclient(const char *arg
) {
137 for(c
= sel
->prev
; c
&& !isvisible(c
); c
= c
->prev
);
139 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
140 for(; c
&& !isvisible(c
); c
= c
->prev
);
144 for(c
= sel
->next
; c
&& !isvisible(c
); c
= c
->next
);
146 for(c
= clients
; c
&& !isvisible(c
); c
= c
->next
);
155 inchratio(const char *arg
) {
156 incratio(arg
, &hratio
, HRATIO
);
160 incvratio(const char *arg
) {
161 incratio(arg
, &vratio
, VRATIO
);
165 incnmaster(const char *arg
) {
172 if((lt
->arrange
!= tile
) || (nmaster
+ i
< 1)
173 || (wah
/ (nmaster
+ i
) <= 2 * BORDERPX
))
188 nlayouts
= sizeof layout
/ sizeof layout
[0];
189 for(blw
= i
= 0; i
< nlayouts
; i
++) {
190 w
= textw(layout
[i
].symbol
);
197 nexttiled(Client
*c
) {
198 for(; c
&& (c
->isfloating
|| !isvisible(c
)); c
= c
->next
);
211 if(sel
->isfloating
|| lt
->arrange
== floating
)
212 XRaiseWindow(dpy
, sel
->win
);
213 if(lt
->arrange
!= floating
) {
214 wc
.stack_mode
= Below
;
216 if(!sel
->isfloating
) {
217 XConfigureWindow(dpy
, sel
->win
, CWSibling
| CWStackMode
, &wc
);
218 wc
.sibling
= sel
->win
;
220 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
223 XConfigureWindow(dpy
, c
->win
, CWSibling
| CWStackMode
, &wc
);
228 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
232 setlayout(const char *arg
) {
237 if(lt
== layout
+ nlayouts
)
242 if(i
< 0 || i
>= nlayouts
)
253 togglebar(const char *arg
) {
255 bpos
= (BARPOS
== BarOff
) ? BarTop
: BARPOS
;
263 togglemax(const char *arg
) {
266 if(!sel
|| (lt
->arrange
!= floating
&& !sel
->isfloating
) || sel
->isfixed
)
268 if((sel
->ismax
= !sel
->ismax
)) {
273 resize(sel
, wax
, way
, waw
- 2 * sel
->border
, wah
- 2 * sel
->border
, True
);
276 resize(sel
, sel
->rx
, sel
->ry
, sel
->rw
, sel
->rh
, True
);
278 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
282 zoom(const char *arg
) {
285 if(!sel
|| lt
->arrange
== floating
|| sel
->isfloating
)
287 if((c
= sel
) == nexttiled(clients
))
288 if(!(c
= nexttiled(c
->next
)))