Xinqi Bao's Git
4b4e908d030ec67a3a1218ed4be30fad9684232a
1 /* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
2 * © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
3 * 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 * c
->border
;
43 if(i
+ 1 == (n
< nmaster
? n
: nmaster
)) /* remainder */
47 else { /* tile window */
49 nw
= tw
- 2 * c
->border
;
50 if(th
> 2 * c
->border
) {
51 ny
+= (i
- nmaster
) * th
;
53 if(i
+ 1 == n
) /* remainder */
54 nh
= wah
- th
* (i
- nmaster
);
57 else /* fallback if th <= 2 * c->border */
58 nh
= wah
- 2 * c
->border
;
60 resize(c
, nx
, ny
, nw
, nh
, False
);
65 XMoveWindow(dpy
, c
->win
, c
->x
+ 2 * sw
, c
->y
);
67 if(!sel
|| !isvisible(sel
))
80 for(c
= clients
; c
; c
= c
->next
) {
83 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
);
85 resize(c
, c
->x
, c
->y
, c
->w
, c
->h
, True
);
89 XMoveWindow(dpy
, c
->win
, c
->x
+ 2 * sw
, c
->y
);
92 if(!sel
|| !isvisible(sel
))
98 focusclient(const char *arg
) {
104 for(c
= sel
->prev
; c
&& !isvisible(c
); c
= c
->prev
);
106 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
107 for(; c
&& !isvisible(c
); c
= c
->prev
);
111 for(c
= sel
->next
; c
&& !isvisible(c
); c
= c
->next
);
113 for(c
= clients
; c
&& !isvisible(c
); c
= c
->next
);
122 incmasterw(const char *arg
) {
124 if(lt
->arrange
!= tile
)
127 masterw
= MASTERWIDTH
;
130 if(waw
* (masterw
+ i
) / 1000 >= waw
- 2 * BORDERPX
131 || waw
* (masterw
+ i
) / 1000 <= 2 * BORDERPX
)
139 incnmaster(const char *arg
) {
146 if((lt
->arrange
!= tile
) || (nmaster
+ i
< 1)
147 || (wah
/ (nmaster
+ i
) <= 2 * BORDERPX
))
162 nlayouts
= sizeof layout
/ sizeof layout
[0];
163 for(blw
= i
= 0; i
< nlayouts
; i
++) {
164 w
= textw(layout
[i
].symbol
);
171 nexttiled(Client
*c
) {
172 for(; c
&& (c
->isfloating
|| !isvisible(c
)); c
= c
->next
);
184 if(sel
->isfloating
|| lt
->arrange
== floating
)
185 XRaiseWindow(dpy
, sel
->win
);
186 if(lt
->arrange
!= floating
) {
188 XLowerWindow(dpy
, sel
->win
);
189 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
192 XLowerWindow(dpy
, c
->win
);
196 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
200 setlayout(const char *arg
) {
205 if(lt
== layout
+ nlayouts
)
210 if(i
< 0 || i
>= nlayouts
)
221 togglebar(const char *arg
) {
223 bpos
= (BARPOS
== BarOff
) ? BarTop
: BARPOS
;
231 togglemax(const char *arg
) {
234 if(!sel
|| (lt
->arrange
!= floating
&& !sel
->isfloating
) || sel
->isfixed
)
236 if((sel
->ismax
= !sel
->ismax
)) {
241 resize(sel
, wax
, way
, waw
- 2 * BORDERPX
, wah
- 2 * BORDERPX
, True
);
244 resize(sel
, sel
->rx
, sel
->ry
, sel
->rw
, sel
->rh
, True
);
246 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
250 zoom(const char *arg
) {
253 if(!sel
|| lt
->arrange
== floating
|| sel
->isfloating
)
255 if((c
= sel
) == nexttiled(clients
))
256 if(!(c
= nexttiled(c
->next
)))