Xinqi Bao's Git
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
) {
202 for(n
= 0, c
= clients
; c
; c
= c
->next
)
203 if(isvisible(c
) && !c
->isfloat
)
205 if(!sel
|| sel
->isfloat
|| n
< 2 || (arrange
== dofloat
))
207 if(sel
== getnext(clients
)) {
208 if(master
+ arg
->i
> 950 || master
+ arg
->i
< 50)
213 if(master
- arg
->i
> 950 || master
- arg
->i
< 50)
229 if(sel
->isfloat
|| arrange
== dofloat
) {
230 XRaiseWindow(dpy
, sel
->win
);
231 XRaiseWindow(dpy
, sel
->twin
);
233 if(arrange
!= dofloat
) {
235 XLowerWindow(dpy
, sel
->twin
);
236 XLowerWindow(dpy
, sel
->win
);
238 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
241 XLowerWindow(dpy
, c
->twin
);
242 XLowerWindow(dpy
, c
->win
);
247 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
251 togglemode(Arg
*arg
) {
252 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
260 toggleview(Arg
*arg
) {
263 seltag
[arg
->i
] = !seltag
[arg
->i
];
264 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
266 seltag
[arg
->i
] = True
; /* cannot toggle last view */
275 for(i
= 0; i
< ntags
; i
++)
277 seltag
[arg
->i
] = True
;
286 for(i
= 0; i
< ntags
; i
++)
299 if(sel
->isfloat
|| (arrange
== dofloat
)) {
303 for(n
= 0, c
= clients
; c
; c
= c
->next
)
304 if(isvisible(c
) && !c
->isfloat
)
306 if(n
< 2 || (arrange
== dofloat
))
308 if((c
= sel
) == nexttiled(clients
))
309 if(!(c
= nexttiled(c
->next
)))