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 for(c
= getnext(c
); c
&& c
->isfloat
; c
= getnext(c
->next
));
19 for(cl
= nexttiled(clients
), i
= 0; cl
&& cl
!= c
; cl
= nexttiled(cl
->next
), i
++);
33 swap(Client
*c1
, Client
*c2
) {
35 Client
*c1p
= c1
->prev
;
36 Client
*c1n
= c1
->next
;
37 Client
*c1s
= c1
->snext
;
38 Client
*c2p
= c2
->prev
;
39 Client
*c2n
= c2
->next
;
40 Client
*c2s
= c2
->snext
;
53 togglemax(Client
*c
) {
59 if((c
->ismax
= !c
->ismax
)) {
60 c
->rx
= c
->x
; c
->x
= wax
;
61 c
->ry
= c
->y
; c
->y
= way
;
62 c
->rw
= c
->w
; c
->w
= waw
- 2 * BORDERPX
;
63 c
->rh
= c
->h
; c
->h
= wah
- 2 * BORDERPX
;
71 resize(c
, True
, TopLeft
);
72 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
80 for(c
= nexttiled(clients
), i
= 0; c
&& i
< nmaster
; c
= nexttiled(c
->next
), i
++);
81 return (i
< nmaster
) ? NULL
: c
;
86 void (*arrange
)(void) = DEFMODE
;
91 c
->prev
->next
= c
->next
;
93 c
->next
->prev
= c
->prev
;
96 c
->next
= c
->prev
= NULL
;
103 for(c
= clients
; c
; c
= c
->next
) {
105 resize(c
, True
, TopLeft
);
110 if(!sel
|| !isvisible(sel
)) {
111 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
119 unsigned int i
, n
, mw
, mh
, tw
, th
;
122 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
125 mw
= (n
> nmaster
) ? (waw
* master
) / 1000 : waw
;
126 mh
= (n
> nmaster
) ? wah
/ nmaster
: wah
/ (n
> 0 ? n
: 1);
128 th
= (n
> nmaster
) ? wah
/ (n
- nmaster
) : 0;
130 for(i
= 0, c
= clients
; c
; c
= c
->next
)
133 resize(c
, True
, TopLeft
);
141 c
->w
= mw
- 2 * BORDERPX
;
142 c
->h
= mh
- 2 * BORDERPX
;
144 else { /* tile window */
146 c
->w
= tw
- 2 * BORDERPX
;
148 c
->y
+= (i
- nmaster
) * th
;
149 c
->h
= th
- 2 * BORDERPX
;
151 else /* fallback if th < bh */
152 c
->h
= wah
- 2 * BORDERPX
;
154 resize(c
, False
, TopLeft
);
160 if(!sel
|| !isvisible(sel
)) {
161 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
168 focusnext(Arg
*arg
) {
173 if(!(c
= getnext(sel
->next
)))
174 c
= getnext(clients
);
182 focusprev(Arg
*arg
) {
187 if(!(c
= getprev(sel
->prev
))) {
188 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
198 incnmaster(Arg
*arg
) {
199 if((nmaster
+ arg
->i
< 1) || (wah
/ (nmaster
+ arg
->i
) < bh
))
206 isvisible(Client
*c
) {
209 for(i
= 0; i
< ntags
; i
++)
210 if(c
->tags
[i
] && seltag
[i
])
216 resizemaster(Arg
*arg
) {
220 if(master
+ arg
->i
> 950 || master
+ arg
->i
< 50)
236 if(sel
->isfloat
|| arrange
== dofloat
) {
237 XRaiseWindow(dpy
, sel
->win
);
238 XRaiseWindow(dpy
, sel
->twin
);
240 if(arrange
!= dofloat
) {
242 XLowerWindow(dpy
, sel
->twin
);
243 XLowerWindow(dpy
, sel
->win
);
245 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
248 XLowerWindow(dpy
, c
->twin
);
249 XLowerWindow(dpy
, c
->win
);
254 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
258 togglefloat(Arg
*arg
) {
259 if (!sel
|| arrange
== dofloat
)
261 sel
->isfloat
= !sel
->isfloat
;
266 togglemode(Arg
*arg
) {
267 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
275 toggleview(Arg
*arg
) {
278 seltag
[arg
->i
] = !seltag
[arg
->i
];
279 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
281 seltag
[arg
->i
] = True
; /* cannot toggle last view */
289 for(i
= 0; i
< ntags
; i
++)
290 seltag
[i
] = (arg
->i
== -1) ? True
: False
;
291 if(arg
->i
>= 0 && arg
->i
< ntags
)
292 seltag
[arg
->i
] = True
;
303 if(sel
->isfloat
|| (arrange
== dofloat
)) {
307 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
311 if(arrange
== dofloat
)
313 else if(n
<= nmaster
)
315 else if(ismaster(sel
)) {
316 if(!(c
= topofstack()))