Xinqi Bao's Git
1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
2 * See LICENSE file for license details.
10 nexttiled(Client
*c
) {
11 for(; c
&& (c
->isfloat
|| !isvisible(c
)); c
= c
->next
);
16 togglemax(Client
*c
) {
22 if((c
->ismax
= !c
->ismax
)) {
27 resize(c
, wax
, way
, waw
- 2 * BORDERPX
, wah
- 2 * BORDERPX
, True
);
30 resize(c
, c
->rx
, c
->ry
, c
->rw
, c
->rh
, True
);
31 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
36 void (*arrange
)(void) = DEFMODE
;
41 c
->prev
->next
= c
->next
;
43 c
->next
->prev
= c
->prev
;
46 c
->next
= c
->prev
= NULL
;
53 for(c
= clients
; c
; c
= c
->next
) {
56 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
);
58 resize(c
, c
->x
, c
->y
, c
->w
, c
->h
, True
);
62 XMoveWindow(dpy
, c
->win
, c
->x
+ 2 * sw
, c
->y
);
65 if(!sel
|| !isvisible(sel
)) {
66 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
74 unsigned int i
, n
, nx
, ny
, nw
, nh
, mw
, mh
, tw
, th
;
77 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
80 mh
= (n
> nmaster
) ? wah
/ nmaster
: wah
/ (n
> 0 ? n
: 1);
81 mw
= (n
> nmaster
) ? (waw
* master
) / 1000 : waw
;
82 th
= (n
> nmaster
) ? wah
/ (n
- nmaster
) : 0;
85 for(i
= 0, c
= clients
; c
; c
= c
->next
)
88 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
);
97 nw
= mw
- 2 * BORDERPX
;
98 nh
= mh
- 2 * BORDERPX
;
100 else { /* tile window */
102 nw
= tw
- 2 * BORDERPX
;
103 if(th
> 2 * BORDERPX
) {
104 ny
+= (i
- nmaster
) * th
;
105 nh
= th
- 2 * BORDERPX
;
107 else /* fallback if th <= 2 * BORDERPX */
108 nh
= wah
- 2 * BORDERPX
;
110 resize(c
, nx
, ny
, nw
, nh
, False
);
115 XMoveWindow(dpy
, c
->win
, c
->x
+ 2 * sw
, c
->y
);
117 if(!sel
|| !isvisible(sel
)) {
118 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
125 focusnext(Arg
*arg
) {
130 for(c
= sel
->next
; c
&& !isvisible(c
); c
= c
->next
);
132 for(c
= clients
; c
&& !isvisible(c
); c
= c
->next
);
140 focusprev(Arg
*arg
) {
145 for(c
= sel
->prev
; c
&& !isvisible(c
); c
= c
->prev
);
147 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
148 for(; c
&& !isvisible(c
); c
= c
->prev
);
157 incnmaster(Arg
*arg
) {
158 if((arrange
== dofloat
) || (nmaster
+ arg
->i
< 1)
159 || (wah
/ (nmaster
+ arg
->i
) <= 2 * BORDERPX
))
169 isvisible(Client
*c
) {
172 for(i
= 0; i
< ntags
; i
++)
173 if(c
->tags
[i
] && seltag
[i
])
179 resizemaster(Arg
*arg
) {
183 if(waw
* (master
+ arg
->i
) / 1000 >= waw
- 2 * BORDERPX
184 || waw
* (master
+ arg
->i
) / 1000 <= 2 * BORDERPX
)
199 if(sel
->isfloat
|| arrange
== dofloat
)
200 XRaiseWindow(dpy
, sel
->win
);
201 if(arrange
!= dofloat
) {
203 XLowerWindow(dpy
, sel
->win
);
204 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
207 XLowerWindow(dpy
, c
->win
);
211 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
215 togglefloat(Arg
*arg
) {
216 if(!sel
|| arrange
== dofloat
)
218 sel
->isfloat
= !sel
->isfloat
;
223 togglemode(Arg
*arg
) {
224 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
232 toggleview(Arg
*arg
) {
235 seltag
[arg
->i
] = !seltag
[arg
->i
];
236 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
238 seltag
[arg
->i
] = True
; /* cannot toggle last view */
246 for(i
= 0; i
< ntags
; i
++)
247 seltag
[i
] = (arg
->i
== -1) ? True
: False
;
248 if(arg
->i
>= 0 && arg
->i
< ntags
)
249 seltag
[arg
->i
] = True
;
260 if(sel
->isfloat
|| (arrange
== dofloat
)) {
264 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
267 if((c
= sel
) == nexttiled(clients
))
268 if(!(c
= nexttiled(c
->next
)))