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
= wax
;
53 c
->ry
= c
->y
; c
->y
= way
;
54 c
->rw
= c
->w
; c
->w
= waw
- 2 * BORDERPX
;
55 c
->rh
= c
->h
; c
->h
= wah
- 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
, th
;
105 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
107 mpx
= (waw
* master
) / 1000;
110 for(i
= 0, c
= clients
; c
; c
= c
->next
)
113 resize(c
, True
, TopLeft
);
119 if(n
== 1) { /* only 1 window */
120 c
->w
= waw
- 2 * BORDERPX
;
121 c
->h
= wah
- 2 * BORDERPX
;
123 else if(i
== 0) { /* master window */
124 c
->w
= waw
- stackw
- 2 * BORDERPX
;
125 c
->h
= wah
- 2 * BORDERPX
;
128 else { /* tile window */
130 c
->w
= stackw
- 2 * BORDERPX
;
132 c
->y
= way
+ (i
- 1) * th
;
133 c
->h
= th
- 2 * BORDERPX
;
135 else /* fallback if th < bh */
136 c
->h
= wah
- 2 * BORDERPX
;
138 resize(c
, False
, TopLeft
);
144 if(!sel
|| !isvisible(sel
)) {
145 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
152 focusnext(Arg
*arg
) {
157 if(!(c
= getnext(sel
->next
)))
158 c
= getnext(clients
);
166 focusprev(Arg
*arg
) {
171 if(!(c
= getprev(sel
->prev
))) {
172 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
182 isvisible(Client
*c
) {
185 for(i
= 0; i
< ntags
; i
++)
186 if(c
->tags
[i
] && seltag
[i
])
192 resizemaster(Arg
*arg
) {
196 if(master
+ arg
->i
> 950 || master
+ arg
->i
< 50)
212 if(sel
->isfloat
|| arrange
== dofloat
) {
213 XRaiseWindow(dpy
, sel
->win
);
214 XRaiseWindow(dpy
, sel
->twin
);
216 if(arrange
!= dofloat
) {
218 XLowerWindow(dpy
, sel
->twin
);
219 XLowerWindow(dpy
, sel
->win
);
221 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
224 XLowerWindow(dpy
, c
->twin
);
225 XLowerWindow(dpy
, c
->win
);
230 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
234 togglemode(Arg
*arg
) {
235 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
243 toggleview(Arg
*arg
) {
246 seltag
[arg
->i
] = !seltag
[arg
->i
];
247 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
249 seltag
[arg
->i
] = True
; /* cannot toggle last view */
258 for(i
= 0; i
< ntags
; i
++)
260 seltag
[arg
->i
] = True
;
269 for(i
= 0; i
< ntags
; i
++)
282 if(sel
->isfloat
|| (arrange
== dofloat
)) {
286 for(n
= 0, c
= clients
; c
; c
= c
->next
)
287 if(isvisible(c
) && !c
->isfloat
)
289 if(n
< 2 || (arrange
== dofloat
))
291 if((c
= sel
) == nexttiled(clients
))
292 if(!(c
= nexttiled(c
->next
)))