Xinqi Bao's Git
de6aef63903ed61a5a922cb2c9e97d156c4062cf
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
;
20 XMoveWindow(dpy
, c
->win
, c
->x
+ 2 * sw
, c
->y
);
28 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
);
34 unsigned int i
, n
, nx
, ny
, nw
, nh
, mw
, mh
, tw
, th
;
37 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
40 mh
= (n
> nmaster
) ? wah
/ nmaster
: wah
/ (n
> 0 ? n
: 1);
41 mw
= (n
> nmaster
) ? (waw
* masterw
) / 1000 : waw
;
42 th
= (n
> nmaster
) ? wah
/ (n
- nmaster
) : 0;
45 for(i
= 0, c
= clients
; c
; c
= c
->next
)
55 nw
= mw
- 2 * c
->border
;
57 if(i
+ 1 == (n
< nmaster
? n
: nmaster
)) /* remainder */
61 else { /* tile window */
63 nw
= tw
- 2 * c
->border
;
64 if(th
> 2 * c
->border
) {
65 ny
+= (i
- nmaster
) * th
;
67 if(i
+ 1 == n
) /* remainder */
68 nh
= wah
- th
* (i
- nmaster
);
71 else /* fallback if th <= 2 * c->border */
72 nh
= wah
- 2 * c
->border
;
74 resize(c
, nx
, ny
, nw
, nh
, False
);
91 for(c
= clients
; c
; c
= c
->next
)
94 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
);
96 resize(c
, c
->x
, c
->y
, c
->w
, c
->h
, True
);
105 focusclient(const char *arg
) {
111 for(c
= sel
->prev
; c
&& !isvisible(c
); c
= c
->prev
);
113 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
114 for(; c
&& !isvisible(c
); c
= c
->prev
);
118 for(c
= sel
->next
; c
&& !isvisible(c
); c
= c
->next
);
120 for(c
= clients
; c
&& !isvisible(c
); c
= c
->next
);
129 incmasterw(const char *arg
) {
131 if(lt
->arrange
!= tile
)
134 masterw
= MASTERWIDTH
;
137 if(waw
* (masterw
+ i
) / 1000 >= waw
- 2 * BORDERPX
138 || waw
* (masterw
+ i
) / 1000 <= 2 * BORDERPX
)
146 incnmaster(const char *arg
) {
153 if((lt
->arrange
!= tile
) || (nmaster
+ i
< 1)
154 || (wah
/ (nmaster
+ i
) <= 2 * BORDERPX
))
169 nlayouts
= sizeof layout
/ sizeof layout
[0];
170 for(blw
= i
= 0; i
< nlayouts
; i
++) {
171 w
= textw(layout
[i
].symbol
);
178 nexttiled(Client
*c
) {
179 for(; c
&& (c
->isfloating
|| !isvisible(c
)); c
= c
->next
);
191 if(sel
->isfloating
|| lt
->arrange
== floating
)
192 XRaiseWindow(dpy
, sel
->win
);
193 if(lt
->arrange
!= floating
) {
195 XLowerWindow(dpy
, sel
->win
);
196 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
199 XLowerWindow(dpy
, c
->win
);
203 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
207 setlayout(const char *arg
) {
212 if(lt
== layout
+ nlayouts
)
217 if(i
< 0 || i
>= nlayouts
)
228 togglebar(const char *arg
) {
230 bpos
= (BARPOS
== BarOff
) ? BarTop
: BARPOS
;
238 togglemax(const char *arg
) {
241 if(!sel
|| (lt
->arrange
!= floating
&& !sel
->isfloating
) || sel
->isfixed
)
243 if((sel
->ismax
= !sel
->ismax
)) {
248 resize(sel
, wax
, way
, waw
- 2 * BORDERPX
, wah
- 2 * BORDERPX
, True
);
251 resize(sel
, sel
->rx
, sel
->ry
, sel
->rw
, sel
->rh
, True
);
253 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
257 zoom(const char *arg
) {
260 if(!sel
|| lt
->arrange
== floating
|| sel
->isfloating
)
262 if((c
= sel
) == nexttiled(clients
))
263 if(!(c
= nexttiled(c
->next
)))