Xinqi Bao's Git
facbb4cbbf7094fae81274ec3aa6f00383a7df59
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 (x
->maxw
&& x
->minw
&& x
->maxh
&& x
->minh
&&
49 x
->maxw
== x
->minw
&& x
->maxh
== x
->minh
)
52 if((c
->ismax
= !c
->ismax
)) {
53 c
->rx
= c
->x
; c
->x
= sx
;
54 c
->ry
= c
->y
; c
->y
= bh
;
55 c
->rw
= c
->w
; c
->w
= sw
- 2 * BORDERPX
;
56 c
->rh
= c
->h
; c
->h
= sh
- bh
- 2 * BORDERPX
;
64 resize(c
, True
, TopLeft
);
65 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
70 void (*arrange
)(void) = DEFMODE
;
75 c
->prev
->next
= c
->next
;
77 c
->next
->prev
= c
->prev
;
80 c
->next
= c
->prev
= NULL
;
87 for(c
= clients
; c
; c
= c
->next
) {
89 resize(c
, True
, TopLeft
);
94 if(!sel
|| !isvisible(sel
)) {
95 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
103 unsigned int i
, n
, mpx
, stackw
, stackh
, th
;
106 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
108 mpx
= (sw
* master
) / 1000;
115 for(i
= 0, c
= clients
; c
; c
= c
->next
)
118 resize(c
, True
, TopLeft
);
124 if(n
== 1) { /* only 1 window */
125 c
->w
= sw
- 2 * BORDERPX
;
126 c
->h
= sh
- 2 * BORDERPX
- bh
;
128 else if(i
== 0) { /* master window */
129 c
->w
= mpx
- 2 * BORDERPX
;
130 c
->h
= sh
- bh
- 2 * BORDERPX
;
132 else { /* tile window */
134 c
->w
= stackw
- 2 * BORDERPX
;
136 c
->y
= sy
+ (i
- 1) * th
+ bh
;
138 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
140 c
->h
= th
- 2 * BORDERPX
;
142 else /* fallback if th < bh */
143 c
->h
= stackh
- 2 * BORDERPX
;
145 resize(c
, False
, TopLeft
);
151 if(!sel
|| !isvisible(sel
)) {
152 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
159 focusnext(Arg
*arg
) {
164 if(!(c
= getnext(sel
->next
)))
165 c
= getnext(clients
);
173 focusprev(Arg
*arg
) {
178 if(!(c
= getprev(sel
->prev
))) {
179 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
189 isvisible(Client
*c
) {
192 for(i
= 0; i
< ntags
; i
++)
193 if(c
->tags
[i
] && seltag
[i
])
199 resizecol(Arg
*arg
) {
203 for(n
= 0, c
= clients
; c
; c
= c
->next
)
204 if(isvisible(c
) && !c
->isfloat
)
206 if(!sel
|| sel
->isfloat
|| n
< 2 || (arrange
== dofloat
))
208 if(sel
== getnext(clients
)) {
209 if(master
+ arg
->i
> 950 || master
+ arg
->i
< 50)
214 if(master
- arg
->i
> 950 || master
- arg
->i
< 50)
230 if(sel
->isfloat
|| arrange
== dofloat
) {
231 XRaiseWindow(dpy
, sel
->win
);
232 XRaiseWindow(dpy
, sel
->twin
);
234 if(arrange
!= dofloat
) {
236 XLowerWindow(dpy
, sel
->twin
);
237 XLowerWindow(dpy
, sel
->win
);
239 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
242 XLowerWindow(dpy
, c
->twin
);
243 XLowerWindow(dpy
, c
->win
);
248 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
252 togglemode(Arg
*arg
) {
253 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
261 toggleview(Arg
*arg
) {
264 seltag
[arg
->i
] = !seltag
[arg
->i
];
265 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
267 seltag
[arg
->i
] = True
; /* cannot toggle last view */
276 for(i
= 0; i
< ntags
; i
++)
278 seltag
[arg
->i
] = True
;
287 for(i
= 0; i
< ntags
; i
++)
300 if(sel
->isfloat
|| (arrange
== dofloat
)) {
304 for(n
= 0, c
= clients
; c
; c
= c
->next
)
305 if(isvisible(c
) && !c
->isfloat
)
307 if(n
< 2 || (arrange
== dofloat
))
309 if((c
= sel
) == nexttiled(clients
))
310 if(!(c
= nexttiled(c
->next
)))