Xinqi Bao's Git
4f42abe4bf06894ab436f6dd5c6ff4e38b8c63c2
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
) {
51 if((c
->ismax
= !c
->ismax
)) {
52 c
->rx
= c
->x
; c
->x
= sx
;
53 c
->ry
= c
->y
; c
->y
= bh
;
54 c
->rw
= c
->w
; c
->w
= sw
- 2 * BORDERPX
;
55 c
->rh
= c
->h
; c
->h
= sh
- bh
- 2 * BORDERPX
;
63 resize(c
, True
, TopLeft
);
64 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
69 void (*arrange
)(void) = DEFMODE
;
74 c
->prev
->next
= c
->next
;
76 c
->next
->prev
= c
->prev
;
79 c
->next
= c
->prev
= NULL
;
86 for(c
= clients
; c
; c
= c
->next
) {
88 resize(c
, True
, TopLeft
);
93 if(!sel
|| !isvisible(sel
)) {
94 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
102 unsigned int i
, n
, mpx
, stackw
, stackh
, th
;
105 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
107 mpx
= (sw
* master
) / 1000;
114 for(i
= 0, c
= clients
; c
; c
= c
->next
)
117 resize(c
, True
, TopLeft
);
123 if(n
== 1) { /* only 1 window */
124 c
->w
= sw
- 2 * BORDERPX
;
125 c
->h
= sh
- 2 * BORDERPX
- bh
;
127 else if(i
== 0) { /* master window */
128 c
->w
= mpx
- 2 * BORDERPX
;
129 c
->h
= sh
- bh
- 2 * BORDERPX
;
131 else { /* tile window */
133 c
->w
= stackw
- 2 * BORDERPX
;
135 c
->y
= sy
+ (i
- 1) * th
+ bh
;
137 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
139 c
->h
= th
- 2 * BORDERPX
;
141 else /* fallback if th < bh */
142 c
->h
= stackh
- 2 * BORDERPX
;
144 resize(c
, False
, TopLeft
);
150 if(!sel
|| !isvisible(sel
)) {
151 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
158 focusnext(Arg
*arg
) {
163 if(!(c
= getnext(sel
->next
)))
164 c
= getnext(clients
);
172 focusprev(Arg
*arg
) {
177 if(!(c
= getprev(sel
->prev
))) {
178 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
188 isvisible(Client
*c
) {
191 for(i
= 0; i
< ntags
; i
++)
192 if(c
->tags
[i
] && seltag
[i
])
198 resizecol(Arg
*arg
) {
199 if(master
+ arg
->i
> 950 || master
+ arg
->i
< 50)
214 if(sel
->isfloat
|| arrange
== dofloat
) {
215 XRaiseWindow(dpy
, sel
->win
);
216 XRaiseWindow(dpy
, sel
->twin
);
218 if(arrange
!= dofloat
) {
220 XLowerWindow(dpy
, sel
->twin
);
221 XLowerWindow(dpy
, sel
->win
);
223 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
226 XLowerWindow(dpy
, c
->twin
);
227 XLowerWindow(dpy
, c
->win
);
232 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
236 togglemode(Arg
*arg
) {
237 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
245 toggleview(Arg
*arg
) {
248 seltag
[arg
->i
] = !seltag
[arg
->i
];
249 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
251 seltag
[arg
->i
] = True
; /* cannot toggle last view */
260 for(i
= 0; i
< ntags
; i
++)
262 seltag
[arg
->i
] = True
;
271 for(i
= 0; i
< ntags
; i
++)
284 if(sel
->isfloat
|| (arrange
== dofloat
)) {
288 for(n
= 0, c
= clients
; c
; c
= c
->next
)
289 if(isvisible(c
) && !c
->isfloat
)
291 if(n
< 2 || (arrange
== dofloat
))
293 if((c
= sel
) == nexttiled(clients
))
294 if(!(c
= nexttiled(c
->next
)))