Xinqi Bao's Git
e5f635c7542d4d0963cc7094d78fc51e2364783b
1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
2 * See LICENSE file for license details.
6 unsigned int master
= MASTER
;
7 unsigned int nmaster
= NMASTER
;
13 static unsigned int nlayouts
= 0;
17 unsigned int i
, n
, nx
, ny
, nw
, nh
, mw
, mh
, tw
, th
;
20 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
23 mh
= (n
> nmaster
) ? wah
/ nmaster
: wah
/ (n
> 0 ? n
: 1);
24 mw
= (n
> nmaster
) ? (waw
* master
) / 1000 : waw
;
25 th
= (n
> nmaster
) ? wah
/ (n
- nmaster
) : 0;
28 for(i
= 0, c
= clients
; c
; c
= c
->next
)
31 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
);
40 nw
= mw
- 2 * BORDERPX
;
41 nh
= mh
- 2 * BORDERPX
;
43 else { /* tile window */
45 nw
= tw
- 2 * BORDERPX
;
46 if(th
> 2 * BORDERPX
) {
47 ny
+= (i
- nmaster
) * th
;
48 nh
= th
- 2 * BORDERPX
;
50 else /* fallback if th <= 2 * BORDERPX */
51 nh
= wah
- 2 * BORDERPX
;
53 resize(c
, nx
, ny
, nw
, nh
, False
);
58 XMoveWindow(dpy
, c
->win
, c
->x
+ 2 * sw
, c
->y
);
60 if(!sel
|| !isvisible(sel
)) {
61 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
77 for(c
= sel
->next
; c
&& !isvisible(c
); c
= c
->next
);
79 for(c
= clients
; c
&& !isvisible(c
); c
= c
->next
);
92 for(c
= sel
->prev
; c
&& !isvisible(c
); c
= c
->prev
);
94 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
95 for(; c
&& !isvisible(c
); c
= c
->prev
);
104 incnmaster(Arg
*arg
) {
105 if((lt
->arrange
!= tile
) || (nmaster
+ arg
->i
< 1)
106 || (wah
/ (nmaster
+ arg
->i
) <= 2 * BORDERPX
))
120 nlayouts
= sizeof layout
/ sizeof layout
[0];
121 for(blw
= i
= 0; i
< nlayouts
; i
++) {
122 w
= textw(layout
[i
].symbol
);
129 nexttiled(Client
*c
) {
130 for(; c
&& (c
->isversatile
|| !isvisible(c
)); c
= c
->next
);
135 resizemaster(Arg
*arg
) {
136 if(lt
->arrange
!= tile
)
141 if(waw
* (master
+ arg
->i
) / 1000 >= waw
- 2 * BORDERPX
142 || waw
* (master
+ arg
->i
) / 1000 <= 2 * BORDERPX
)
157 if(sel
->isversatile
|| lt
->arrange
== versatile
)
158 XRaiseWindow(dpy
, sel
->win
);
159 if(lt
->arrange
!= versatile
) {
160 if(!sel
->isversatile
)
161 XLowerWindow(dpy
, sel
->win
);
162 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
165 XLowerWindow(dpy
, c
->win
);
169 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
173 setlayout(Arg
*arg
) {
177 for(i
= 0; i
< nlayouts
&& lt
!= &layout
[i
]; i
++);
178 if(i
== nlayouts
- 1)
184 if(arg
->i
< 0 || arg
->i
>= nlayouts
)
186 lt
= &layout
[arg
->i
];
198 for(c
= clients
; c
; c
= c
->next
) {
201 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
);
203 resize(c
, c
->x
, c
->y
, c
->w
, c
->h
, True
);
207 XMoveWindow(dpy
, c
->win
, c
->x
+ 2 * sw
, c
->y
);
210 if(!sel
|| !isvisible(sel
)) {
211 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);