Xinqi Bao's Git
ac1728b8b8f3dbdac7bb3bd56e6b87f4da409ec9
1 /* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * See LICENSE file for license details.
12 if((clients
&& clients
->isfloat
) || arrange
== dofloat
)
13 return clients
; /* don't touch floating order */
14 for(min
= c
= clients
; c
; c
= c
->next
)
15 if(c
->weight
< min
->weight
)
21 nexttiled(Client
*c
) {
22 for(c
= getnext(c
); c
&& c
->isfloat
; c
= getnext(c
->next
));
28 Client
*c
, *newclients
, *tail
;
30 newclients
= tail
= NULL
;
31 while((c
= minclient())) {
39 tail
= newclients
= c
;
45 togglemax(Client
*c
) {
48 if((c
->ismax
= !c
->ismax
)) {
49 c
->rx
= c
->x
; c
->x
= sx
;
50 c
->ry
= c
->y
; c
->y
= bh
;
51 c
->rw
= c
->w
; c
->w
= sw
- 2 * BORDERPX
;
52 c
->rh
= c
->h
; c
->h
= sh
- bh
- 2 * BORDERPX
;
60 resize(c
, True
, TopLeft
);
61 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
66 void (*arrange
)(void) = DEFMODE
;
71 c
->prev
->next
= c
->next
;
73 c
->next
->prev
= c
->prev
;
76 c
->next
= c
->prev
= NULL
;
83 for(c
= clients
; c
; c
= c
->next
) {
85 resize(c
, True
, TopLeft
);
90 if(!sel
|| !isvisible(sel
)) {
91 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
99 unsigned int i
, n
, mpx
, stackw
, stackh
, th
;
102 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
104 mpx
= (sw
* master
) / 1000;
111 for(i
= 0, c
= clients
; c
; c
= c
->next
, i
++)
114 resize(c
, True
, TopLeft
);
120 if(n
== 1) { /* only 1 window */
121 c
->w
= sw
- 2 * BORDERPX
;
122 c
->h
= sh
- 2 * BORDERPX
- bh
;
124 else if(i
== 0) { /* master window */
125 c
->w
= mpx
- 2 * BORDERPX
;
126 c
->h
= sh
- bh
- 2 * BORDERPX
;
128 else { /* tile window */
130 c
->w
= stackw
- 2 * BORDERPX
;
132 c
->y
= sy
+ (i
- 1) * th
+ bh
;
134 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
136 c
->h
= th
- 2 * BORDERPX
;
138 else /* fallback if th < bh */
139 c
->h
= stackh
- 2 * BORDERPX
;
141 resize(c
, False
, TopLeft
);
146 if(!sel
|| !isvisible(sel
)) {
147 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
154 focusnext(Arg
*arg
) {
159 if(!(c
= getnext(sel
->next
)))
160 c
= getnext(clients
);
168 focusprev(Arg
*arg
) {
173 if(!(c
= getprev(sel
->prev
))) {
174 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
184 isvisible(Client
*c
) {
187 for(i
= 0; i
< ntags
; i
++)
188 if(c
->tags
[i
] && seltag
[i
])
194 resizecol(Arg
*arg
) {
198 for(n
= 0, c
= clients
; c
; c
= c
->next
)
199 if(isvisible(c
) && !c
->isfloat
)
201 if(!sel
|| sel
->isfloat
|| n
< 2 || (arrange
== dofloat
))
203 if(sel
== getnext(clients
)) {
204 if(master
+ arg
->i
> 950 || master
+ arg
->i
< 50)
209 if(master
- arg
->i
> 950 || master
- arg
->i
< 50)
225 if(sel
->isfloat
|| arrange
== dofloat
) {
226 XRaiseWindow(dpy
, sel
->win
);
227 XRaiseWindow(dpy
, sel
->twin
);
229 if(arrange
!= dofloat
) {
231 XLowerWindow(dpy
, sel
->twin
);
232 XLowerWindow(dpy
, sel
->win
);
234 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
237 XLowerWindow(dpy
, c
->twin
);
238 XLowerWindow(dpy
, c
->win
);
243 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
247 togglemode(Arg
*arg
) {
248 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
256 toggleview(Arg
*arg
) {
259 seltag
[arg
->i
] = !seltag
[arg
->i
];
260 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
262 seltag
[arg
->i
] = True
; /* cannot toggle last view */
271 for(i
= 0; i
< ntags
; i
++)
273 seltag
[arg
->i
] = True
;
282 for(i
= 0; i
< ntags
; i
++)
295 if(sel
->isfloat
|| (arrange
== dofloat
)) {
299 for(n
= 0, c
= clients
; c
; c
= c
->next
)
300 if(isvisible(c
) && !c
->isfloat
)
302 if(n
< 2 || (arrange
== dofloat
))
304 if((c
= sel
) == nexttiled(clients
))
305 if(!(c
= nexttiled(c
->next
)))