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
*c2p
= c2
->prev
;
38 Client
*c2n
= c2
->next
;
49 togglemax(Client
*c
) {
55 if((c
->ismax
= !c
->ismax
)) {
56 c
->rx
= c
->x
; c
->x
= wax
;
57 c
->ry
= c
->y
; c
->y
= way
;
58 c
->rw
= c
->w
; c
->w
= waw
- 2 * BORDERPX
;
59 c
->rh
= c
->h
; c
->h
= wah
- 2 * BORDERPX
;
67 resize(c
, True
, TopLeft
);
68 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
76 for(c
= nexttiled(clients
), i
= 0; c
&& i
< nmaster
; c
= nexttiled(c
->next
), i
++);
77 return (i
< nmaster
) ? NULL
: c
;
82 void (*arrange
)(void) = DEFMODE
;
87 c
->prev
->next
= c
->next
;
89 c
->next
->prev
= c
->prev
;
92 c
->next
= c
->prev
= NULL
;
99 for(c
= clients
; c
; c
= c
->next
) {
101 resize(c
, True
, TopLeft
);
106 if(!sel
|| !isvisible(sel
)) {
107 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
115 unsigned int i
, n
, mw
, mh
, tw
, th
;
118 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
121 mw
= (n
> nmaster
) ? (waw
* master
) / 1000 : waw
;
122 mh
= (n
> nmaster
) ? wah
/ nmaster
: wah
/ (n
> 0 ? n
: 1);
124 th
= (n
> nmaster
) ? wah
/ (n
- nmaster
) : 0;
126 for(i
= 0, c
= clients
; c
; c
= c
->next
)
129 resize(c
, True
, TopLeft
);
137 c
->w
= mw
- 2 * BORDERPX
;
138 c
->h
= mh
- 2 * BORDERPX
;
140 else { /* tile window */
142 c
->w
= tw
- 2 * BORDERPX
;
144 c
->y
+= (i
- nmaster
) * th
;
145 c
->h
= th
- 2 * BORDERPX
;
147 else /* fallback if th < bh */
148 c
->h
= wah
- 2 * BORDERPX
;
150 resize(c
, False
, TopLeft
);
156 if(!sel
|| !isvisible(sel
)) {
157 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
164 focusnext(Arg
*arg
) {
169 if(!(c
= getnext(sel
->next
)))
170 c
= getnext(clients
);
178 focusprev(Arg
*arg
) {
183 if(!(c
= getprev(sel
->prev
))) {
184 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
194 incnmaster(Arg
*arg
) {
195 if((nmaster
+ arg
->i
< 1) || (wah
/ (nmaster
+ arg
->i
) < bh
))
202 isvisible(Client
*c
) {
205 for(i
= 0; i
< ntags
; i
++)
206 if(c
->tags
[i
] && seltag
[i
])
212 resizemaster(Arg
*arg
) {
216 if(master
+ arg
->i
> 950 || master
+ arg
->i
< 50)
232 if(sel
->isfloat
|| arrange
== dofloat
) {
233 XRaiseWindow(dpy
, sel
->win
);
234 XRaiseWindow(dpy
, sel
->twin
);
236 if(arrange
!= dofloat
) {
238 XLowerWindow(dpy
, sel
->twin
);
239 XLowerWindow(dpy
, sel
->win
);
241 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
244 XLowerWindow(dpy
, c
->twin
);
245 XLowerWindow(dpy
, c
->win
);
250 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
254 togglefloat(Arg
*arg
) {
255 if (!sel
|| arrange
== dofloat
)
257 sel
->isfloat
= !sel
->isfloat
;
262 togglemode(Arg
*arg
) {
263 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
271 toggleview(Arg
*arg
) {
274 seltag
[arg
->i
] = !seltag
[arg
->i
];
275 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
277 seltag
[arg
->i
] = True
; /* cannot toggle last view */
285 for(i
= 0; i
< ntags
; i
++)
286 seltag
[i
] = (arg
->i
== -1) ? True
: False
;
287 if(arg
->i
>= 0 && arg
->i
< ntags
)
288 seltag
[arg
->i
] = True
;
299 if(sel
->isfloat
|| (arrange
== dofloat
)) {
303 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
307 if(arrange
== dofloat
)
309 else if(n
<= nmaster
)
311 else if(ismaster(sel
)) {
312 if(!(c
= topofstack()))