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
))
79 mw
= (n
> nmaster
) ? (waw
* master
) / 1000 : waw
;
80 mh
= (n
> nmaster
) ? wah
/ nmaster
: wah
/ (n
> 0 ? n
: 1);
82 th
= (n
> nmaster
) ? wah
/ (n
- nmaster
) : 0;
84 for(i
= 0, c
= clients
; c
; c
= c
->next
)
87 resize(c
, True
, TopLeft
);
95 c
->w
= mw
- 2 * BORDERPX
;
96 c
->h
= mh
- 2 * BORDERPX
;
98 else { /* tile window */
100 c
->w
= tw
- 2 * BORDERPX
;
102 c
->y
+= (i
- nmaster
) * th
;
103 c
->h
= th
- 2 * BORDERPX
;
105 else /* fallback if th < bh */
106 c
->h
= wah
- 2 * BORDERPX
;
108 resize(c
, False
, TopLeft
);
114 if(!sel
|| !isvisible(sel
)) {
115 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
122 focusnext(Arg
*arg
) {
127 if(!(c
= getnext(sel
->next
)))
128 c
= getnext(clients
);
136 focusprev(Arg
*arg
) {
141 if(!(c
= getprev(sel
->prev
))) {
142 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
152 incnmaster(Arg
*arg
) {
153 if((arrange
== dofloat
) || (nmaster
+ arg
->i
< 1) || (wah
/ (nmaster
+ arg
->i
) < bh
))
156 snprintf(mtext
, sizeof mtext
, arrange
== dofloat
? FLOATSYMBOL
: TILESYMBOL
, nmaster
);
165 isvisible(Client
*c
) {
168 for(i
= 0; i
< ntags
; i
++)
169 if(c
->tags
[i
] && seltag
[i
])
175 resizemaster(Arg
*arg
) {
179 if(master
+ arg
->i
> 950 || master
+ arg
->i
< 50)
195 if(sel
->isfloat
|| arrange
== dofloat
) {
196 XRaiseWindow(dpy
, sel
->win
);
197 XRaiseWindow(dpy
, sel
->twin
);
199 if(arrange
!= dofloat
) {
201 XLowerWindow(dpy
, sel
->twin
);
202 XLowerWindow(dpy
, sel
->win
);
204 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
207 XLowerWindow(dpy
, c
->twin
);
208 XLowerWindow(dpy
, c
->win
);
213 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
217 togglefloat(Arg
*arg
) {
218 if (!sel
|| arrange
== dofloat
)
220 sel
->isfloat
= !sel
->isfloat
;
225 togglemode(Arg
*arg
) {
226 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
227 snprintf(mtext
, sizeof mtext
, arrange
== dofloat
? FLOATSYMBOL
: TILESYMBOL
, nmaster
);
236 toggleview(Arg
*arg
) {
239 seltag
[arg
->i
] = !seltag
[arg
->i
];
240 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
242 seltag
[arg
->i
] = True
; /* cannot toggle last view */
250 for(i
= 0; i
< ntags
; i
++)
251 seltag
[i
] = (arg
->i
== -1) ? True
: False
;
252 if(arg
->i
>= 0 && arg
->i
< ntags
)
253 seltag
[arg
->i
] = True
;
264 if(sel
->isfloat
|| (arrange
== dofloat
)) {
268 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
271 if((c
= sel
) == nexttiled(clients
))
272 if(!(c
= nexttiled(c
->next
)))