Xinqi Bao's Git
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
13 if((clients
&& clients
->isfloat
) || arrange
== dofloat
)
14 return clients
; /* don't touch floating order */
15 for(min
= c
= clients
; c
; c
= c
->next
)
16 if(c
->weight
< min
->weight
)
22 nexttiled(Client
*c
) {
23 for(c
= getnext(c
); c
&& c
->isfloat
; c
= getnext(c
->next
));
29 Client
*c
, *newclients
, *tail
;
31 newclients
= tail
= NULL
;
32 while((c
= minclient())) {
40 tail
= newclients
= c
;
49 if((c
->ismax
= !c
->ismax
)) {
50 c
->rx
= c
->x
; c
->x
= sx
;
51 c
->ry
= c
->y
; c
->y
= bh
;
52 c
->rw
= c
->w
; c
->w
= sw
- 2 * BORDERPX
;
53 c
->rh
= c
->h
; c
->h
= sh
- bh
- 2 * BORDERPX
;
61 resize(c
, True
, TopLeft
);
62 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
67 void (*arrange
)(Arg
*) = DEFMODE
;
72 c
->prev
->next
= c
->next
;
74 c
->next
->prev
= c
->prev
;
77 c
->next
= c
->prev
= NULL
;
84 for(c
= clients
; c
; c
= c
->next
) {
86 resize(c
, True
, TopLeft
);
91 if(!sel
|| !isvisible(sel
)) {
92 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
98 /* This algorithm is based on a (M)aster area and a (S)tacking area.
99 * It supports following arrangements:
105 * The stacking area can be set to arrange clients vertically or horizontally.
106 * Through inverting the algorithm it can be used to achieve following setup in
107 * a dual head environment (due to running two dwm instances concurrently on
108 * the specific screen):
114 * This uses the center of the two screens for master areas.
122 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
126 h
= (sh
- bh
) / (n
- 1);
130 for(i
= 0, c
= clients
; c
; c
= c
->next
) {
133 resize(c
, True
, TopLeft
);
140 c
->w
= sw
- 2 * BORDERPX
;
141 c
->h
= sh
- 2 * BORDERPX
- bh
;
146 c
->w
= mw
- 2 * BORDERPX
;
147 c
->h
= sh
- 2 * BORDERPX
- bh
;
151 c
->y
= sy
+ (i
- 1) * h
+ bh
;
152 c
->w
= w
- 2 * BORDERPX
;
154 c
->h
= sh
- c
->y
- 2 * BORDERPX
;
156 c
->h
= h
- 2 * BORDERPX
;
158 else { /* fallback if h < bh */
161 c
->w
= w
- 2 * BORDERPX
;
162 c
->h
= sh
- 2 * BORDERPX
- bh
;
164 resize(c
, False
, TopLeft
);
170 if(!sel
|| !isvisible(sel
)) {
171 for(c
= stack
; c
&& !isvisible(c
); c
= c
->snext
);
178 focusnext(Arg
*arg
) {
184 if(!(c
= getnext(sel
->next
)))
185 c
= getnext(clients
);
193 focusprev(Arg
*arg
) {
199 if(!(c
= getprev(sel
->prev
))) {
200 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
210 isvisible(Client
*c
) {
213 for(i
= 0; i
< ntags
; i
++)
214 if(c
->tags
[i
] && seltag
[i
])
220 resizecol(Arg
*arg
) {
224 for(n
= 0, c
= clients
; c
; c
= c
->next
)
225 if(isvisible(c
) && !c
->isfloat
)
227 if(!sel
|| sel
->isfloat
|| n
< 2 || (arrange
== dofloat
))
230 if(sel
== getnext(clients
)) {
231 if(mw
+ arg
->i
> sw
- 100 || mw
+ arg
->i
< 100)
236 if(mw
- arg
->i
> sw
- 100 || mw
- arg
->i
< 100)
252 if(sel
->isfloat
|| arrange
== dofloat
) {
253 XRaiseWindow(dpy
, sel
->win
);
254 XRaiseWindow(dpy
, sel
->twin
);
256 if(arrange
!= dofloat
)
257 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
258 XLowerWindow(dpy
, c
->twin
);
259 XLowerWindow(dpy
, c
->win
);
263 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
267 togglemode(Arg
*arg
) {
268 arrange
= (arrange
== dofloat
) ? dotile
: dofloat
;
276 toggleview(Arg
*arg
) {
279 seltag
[arg
->i
] = !seltag
[arg
->i
];
280 for(i
= 0; i
< ntags
&& !seltag
[i
]; i
++);
282 seltag
[arg
->i
] = True
; /* cannot toggle last view */
291 for(i
= 0; i
< ntags
; i
++)
293 seltag
[arg
->i
] = True
;
302 for(i
= 0; i
< ntags
; i
++)
316 if(sel
->isfloat
|| (arrange
== dofloat
)) {
321 for(n
= 0, c
= clients
; c
; c
= c
->next
)
322 if(isvisible(c
) && !c
->isfloat
)
324 if(n
< 2 || (arrange
== dofloat
))
327 if((c
= sel
) == nexttiled(clients
))
328 if(!(c
= nexttiled(c
->next
)))