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
= getnext(c
); c
&& c
->isfloat
; c
= getnext(c
->next
));
16 togglemax(Client
*c
) {
22 if((c
->ismax
= !c
->ismax
)) {
23 c
->rx
= c
->x
; c
->x
= wax
;
24 c
->ry
= c
->y
; c
->y
= way
;
25 c
->rw
= c
->w
; c
->w
= waw
- 2 * BORDERPX
;
26 c
->rh
= c
->h
; c
->h
= wah
- 2 * BORDERPX
;
34 resize(c
, True
, TopLeft
);
35 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
40 void (*arrange
)(void) = DEFMODE
;
45 c
->prev
->next
= c
->next
;
47 c
->next
->prev
= c
->prev
;
50 c
->next
= c
->prev
= NULL
;
57 for(c
= clients
; c
; c
= c
->next
) {
59 resize(c
, True
, TopLeft
);
64 if(!sel
|| !isvisible(sel
)) {
65 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
73 unsigned int i
, n
, mw
, mh
, tw
, th
;
76 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
81 mh
= (n
> nmaster
) ? wah
/ nmaster
: wah
/ (n
> 0 ? n
: 1);
82 mw
= (n
> nmaster
) ? (waw
* master
) / 1000 : waw
;
86 th
= (n
> nmaster
) ? wah
/ (n
- nmaster
) : 0;
89 for(i
= 0, c
= clients
; c
; c
= c
->next
)
92 resize(c
, True
, TopLeft
);
98 if((nmaster
> 0) && (i
< nmaster
)) {
100 c
->w
= mw
- 2 * BORDERPX
;
101 c
->h
= mh
- 2 * BORDERPX
;
103 else { /* tile window */
105 c
->w
= tw
- 2 * BORDERPX
;
107 c
->y
+= (i
- nmaster
) * th
;
108 c
->h
= th
- 2 * BORDERPX
;
110 else /* fallback if th < bh */
111 c
->h
= wah
- 2 * BORDERPX
;
113 resize(c
, False
, TopLeft
);
119 if(!sel
|| !isvisible(sel
)) {
120 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
127 focusnext(Arg
*arg
) {
132 if(!(c
= getnext(sel
->next
)))
133 c
= getnext(clients
);
141 focusprev(Arg
*arg
) {
146 if(!(c
= getprev(sel
->prev
))) {
147 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
157 incnmaster(Arg
*arg
) {
158 if((arrange
== dofloat
)
159 || ((int)nmaster
+ arg
->i
< 0)
160 || (((int)nmaster
+ arg
->i
> 0) && (wah
/ (nmaster
+ arg
->i
) < bh
)))
171 isvisible(Client
*c
) {
174 for(i
= 0; i
< ntags
; i
++)
175 if(c
->tags
[i
] && seltag
[i
])
181 resizemaster(Arg
*arg
) {
185 if(master
+ arg
->i
> 950 || master
+ arg
->i
< 50)
201 if(sel
->isfloat
|| arrange
== dofloat
) {
202 XRaiseWindow(dpy
, sel
->win
);
203 XRaiseWindow(dpy
, sel
->twin
);
205 if(arrange
!= dofloat
) {
207 XLowerWindow(dpy
, sel
->twin
);
208 XLowerWindow(dpy
, sel
->win
);
210 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
213 XLowerWindow(dpy
, c
->twin
);
214 XLowerWindow(dpy
, c
->win
);
219 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
223 togglefloat(Arg
*arg
) {
224 if (!sel
|| arrange
== dofloat
)
226 sel
->isfloat
= !sel
->isfloat
;
231 togglemode(Arg
*arg
) {
232 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
241 toggleview(Arg
*arg
) {
244 seltag
[arg
->i
] = !seltag
[arg
->i
];
245 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
247 seltag
[arg
->i
] = True
; /* cannot toggle last view */
253 snprintf(mtext
, sizeof mtext
, arrange
== dofloat
? FLOATSYMBOL
: TILESYMBOL
, nmaster
);
261 for(i
= 0; i
< ntags
; i
++)
262 seltag
[i
] = (arg
->i
== -1) ? True
: False
;
263 if(arg
->i
>= 0 && arg
->i
< ntags
)
264 seltag
[arg
->i
] = True
;
275 if(sel
->isfloat
|| (arrange
== dofloat
)) {
279 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
282 if((c
= sel
) == nexttiled(clients
))
283 if(!(c
= nexttiled(c
->next
)))