Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
11 static unsigned int nlayouts
= 0;
18 floating(const char *arg
) {
21 if(lt
->arrange
!= floating
)
24 for(c
= clients
; c
; c
= c
->next
)
27 resize(c
, c
->x
, c
->y
, c
->w
, c
->h
, True
);
36 focusclient(const char *arg
) {
42 for(c
= sel
->prev
; c
&& !isvisible(c
); c
= c
->prev
);
44 for(c
= clients
; c
&& c
->next
; c
= c
->next
);
45 for(; c
&& !isvisible(c
); c
= c
->prev
);
49 for(c
= sel
->next
; c
&& !isvisible(c
); c
= c
->next
);
51 for(c
= clients
; c
&& !isvisible(c
); c
= c
->next
);
64 nlayouts
= sizeof layout
/ sizeof layout
[0];
65 for(blw
= i
= 0; i
< nlayouts
; i
++) {
66 w
= textw(layout
[i
].symbol
);
73 nexttiled(Client
*c
) {
74 for(; c
&& (c
->isfloating
|| !isvisible(c
)); c
= c
->next
);
87 if(sel
->isfloating
|| lt
->arrange
== floating
)
88 XRaiseWindow(dpy
, sel
->win
);
89 if(lt
->arrange
!= floating
) {
90 wc
.stack_mode
= Below
;
92 if(!sel
->isfloating
) {
93 XConfigureWindow(dpy
, sel
->win
, CWSibling
| CWStackMode
, &wc
);
94 wc
.sibling
= sel
->win
;
96 for(c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
)) {
99 XConfigureWindow(dpy
, c
->win
, CWSibling
| CWStackMode
, &wc
);
104 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
108 setlayout(const char *arg
) {
113 if(lt
== layout
+ nlayouts
)
118 if(i
< 0 || i
>= nlayouts
)
129 tile(const char *arg
) {
130 static double master
= MASTER
;
132 unsigned int i
, n
, nx
, ny
, nw
, nh
, mw
, th
;
135 if(lt
->arrange
!= tile
)
138 /* arg handling, manipulate master */
139 if(arg
&& (1 == sscanf(arg
, "%lf", &delta
))) {
140 if(delta
+ master
> 0.1 && delta
+ master
< 0.9)
144 for(n
= 0, c
= nexttiled(clients
); c
; c
= nexttiled(c
->next
))
148 mw
= (n
== 1) ? waw
: master
* waw
;
149 th
= (n
> 1) ? wah
/ (n
- 1) : 0;
155 for(i
= 0, c
= clients
; c
; c
= c
->next
)
161 if(i
== 0) { /* master */
162 nw
= mw
- 2 * c
->border
;
163 nh
= wah
- 2 * c
->border
;
165 else { /* tile window */
170 nw
= waw
- mw
- 2 * c
->border
;
171 if(i
+ 1 == n
) /* remainder */
172 nh
= (way
+ wah
) - ny
- 2 * c
->border
;
174 nh
= th
- 2 * c
->border
;
176 resize(c
, nx
, ny
, nw
, nh
, False
);
177 if(n
> 1 && th
!= wah
)
188 togglebar(const char *arg
) {
190 bpos
= (BARPOS
== BarOff
) ? BarTop
: BARPOS
;
198 togglemax(const char *arg
) {
201 if(!sel
|| (lt
->arrange
!= floating
&& !sel
->isfloating
) || sel
->isfixed
)
203 if((sel
->ismax
= !sel
->ismax
)) {
208 resize(sel
, wax
, way
, waw
- 2 * sel
->border
, wah
- 2 * sel
->border
, True
);
211 resize(sel
, sel
->rx
, sel
->ry
, sel
->rw
, sel
->rh
, True
);
213 while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
));
217 zoom(const char *arg
) {
220 if(!sel
|| lt
->arrange
== floating
|| sel
->isfloating
)
222 if((c
= sel
) == nexttiled(clients
))
223 if(!(c
= nexttiled(c
->next
)))