Xinqi Bao's Git
8756e0018c8a95cbd6a9bfcf73012a8085429b3a
1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
2 * See LICENSE file for license details.
12 static unsigned int nlayouts
= 0;
13 static unsigned int masterw
= MASTERWIDTH
;
14 static unsigned int nmaster
= NMASTER
;
18 unsigned int i
, n
, nx
, ny
, nw
, nh
, mw
, mh
, tw
, th
;
21 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
24 mh
= (n
> nmaster
) ? wah
/ nmaster
: wah
/ (n
> 0 ? n
: 1);
25 mw
= (n
> nmaster
) ? (waw
* masterw
) / 1000 : waw
;
26 th
= (n
> nmaster
) ? wah
/ (n
- nmaster
) : 0;
29 for(i
= 0, c
= clients
; c
; c
= c
->next
)
32 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
);
41 nw
= mw
- 2 * BORDERPX
;
42 nh
= mh
- 2 * BORDERPX
;
44 else { /* tile window */
46 nw
= tw
- 2 * BORDERPX
;
47 if(th
> 2 * BORDERPX
) {
48 ny
+= (i
- nmaster
) * th
;
49 nh
= th
- 2 * BORDERPX
;
51 else /* fallback if th <= 2 * BORDERPX */
52 nh
= wah
- 2 * BORDERPX
;
54 resize(c
, nx
, ny
, nw
, nh
, False
);
59 XMoveWindow(dpy
, c
->win
, c
->x
+ 2 * sw
, c
->y
);
61 if(!sel
|| !isvisible(sel
)) {
62 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
73 focusclient(const char *arg
) {
79 for(c
= sel
->prev
; c
&& !isvisible(c
); c
= c
->prev
);
81 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
82 for(; c
&& !isvisible(c
); c
= c
->prev
);
86 for(c
= sel
->next
; c
&& !isvisible(c
); c
= c
->next
);
88 for(c
= clients
; c
&& !isvisible(c
); c
= c
->next
);
97 incmasterw(const char *arg
) {
99 if(lt
->arrange
!= tile
)
102 masterw
= MASTERWIDTH
;
105 if(waw
* (masterw
+ i
) / 1000 >= waw
- 2 * BORDERPX
106 || waw
* (masterw
+ i
) / 1000 <= 2 * BORDERPX
)
114 incnmaster(const char *arg
) {
121 if((lt
->arrange
!= tile
) || (nmaster
+ i
< 1)
122 || (wah
/ (nmaster
+ i
) <= 2 * BORDERPX
))
137 nlayouts
= sizeof layout
/ sizeof layout
[0];
138 for(blw
= i
= 0; i
< nlayouts
; i
++) {
139 w
= textw(layout
[i
].symbol
);
146 nexttiled(Client
*c
) {
147 for(; c
&& (c
->isuntiled
|| !isvisible(c
)); c
= c
->next
);
159 if(sel
->isuntiled
|| lt
->arrange
== untile
)
160 XRaiseWindow(dpy
, sel
->win
);
161 if(lt
->arrange
!= untile
) {
163 XLowerWindow(dpy
, sel
->win
);
164 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
167 XLowerWindow(dpy
, c
->win
);
171 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
175 setlayout(const char *arg
) {
179 for(i
= 0; i
< nlayouts
&& lt
!= &layout
[i
]; i
++);
180 if(i
== nlayouts
- 1)
187 if(i
< 0 || i
>= nlayouts
)
198 togglemax(const char *arg
) {
201 if(!sel
|| (lt
->arrange
!= untile
&& !sel
->isuntiled
) || sel
->isfixed
)
203 if((sel
->ismax
= !sel
->ismax
)) {
208 resize(sel
, wax
, way
, waw
- 2 * BORDERPX
, wah
- 2 * BORDERPX
, True
);
211 resize(sel
, sel
->rx
, sel
->ry
, sel
->rw
, sel
->rh
, True
);
213 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
220 for(c
= clients
; c
; c
= c
->next
) {
223 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
);
225 resize(c
, c
->x
, c
->y
, c
->w
, c
->h
, True
);
229 XMoveWindow(dpy
, c
->win
, c
->x
+ 2 * sw
, c
->y
);
232 if(!sel
|| !isvisible(sel
)) {
233 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
240 zoom(const char *arg
) {
244 if(!sel
|| lt
->arrange
!= tile
|| sel
->isuntiled
)
246 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
248 if((c
= sel
) == nexttiled(clients
))
249 if(!(c
= nexttiled(c
->next
)))