4 * Copyright © 2007 Julien Danjou <julien@danjou.info>
5 * Copyright © 2007 Ross Mohn <rpmohn@waxandwane.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "layouts/tile.h"
31 extern Client
*sel
, *clients
;
36 static double mwfact
= 0.6;
37 static int nmaster
= 2;
40 uicb_setnmaster(Display
*disp
,
41 awesome_config
*awesomeconf
,
45 int wah
= get_windows_area_height(disp
, awesomeconf
->statusbar
);
47 if(!IS_ARRANGE(tile
) && !IS_ARRANGE(tileleft
) && !IS_ARRANGE(bstack
) && !IS_ARRANGE(bstackportrait
))
50 nmaster
= awesomeconf
->nmaster
;
51 else if(sscanf(arg
, "%d", &delta
))
53 if((arg
[0] == '+' || arg
[0] == '-')
54 && !((nmaster
+ delta
) < 1 || wah
/ (nmaster
+ delta
) <= 2 * awesomeconf
->borderpx
))
56 else if(delta
>= 1 && wah
/ delta
<= 2 * awesomeconf
->borderpx
)
62 arrange(disp
, awesomeconf
);
64 drawstatus(disp
, &dc
, awesomeconf
);
68 uicb_setmwfact(Display
*disp
,
69 awesome_config
* awesomeconf
,
74 if(!IS_ARRANGE(tile
) && !IS_ARRANGE(tileleft
) && !IS_ARRANGE(bstack
) && !IS_ARRANGE(bstackportrait
))
77 /* arg handling, manipulate mwfact */
79 mwfact
= awesomeconf
->mwfact
;
80 else if(sscanf(arg
, "%lf", &delta
))
82 if(arg
[0] != '+' && arg
[0] != '-')
91 arrange(disp
, awesomeconf
);
95 _tile(Display
*disp
, awesome_config
*awesomeconf
, const Bool right
)
97 int wah
= get_windows_area_height(disp
, awesomeconf
->statusbar
);
98 int waw
= get_windows_area_width(disp
, awesomeconf
->statusbar
);
99 int wax
= get_windows_area_x(awesomeconf
->statusbar
);
100 int way
= get_windows_area_y(awesomeconf
->statusbar
);
101 unsigned int nx
, ny
, nw
, nh
, mw
;
105 for(n
= 0, c
= clients
; c
; c
= c
->next
)
106 if(IS_TILED(c
, awesomeconf
->selected_tags
, awesomeconf
->ntags
))
110 mh
= (n
<= nmaster
) ? wah
/ (n
> 0 ? n
: 1) : wah
/ nmaster
;
111 mw
= (n
<= nmaster
) ? waw
: mwfact
* waw
;
112 th
= (n
> nmaster
) ? wah
/ (n
- nmaster
) : 0;
113 if(n
> nmaster
&& th
< awesomeconf
->statusbar
.height
)
118 for(i
= 0, c
= clients
; c
; c
= c
->next
)
120 if(!IS_TILED(c
, awesomeconf
->selected_tags
, awesomeconf
->ntags
))
129 nw
= mw
- 2 * c
->border
;
131 if(i
+ 1 == (n
< nmaster
? n
: nmaster
)) /* remainder */
145 nw
= waw
- mw
- 2 * c
->border
;
146 if(i
+ 1 == n
) /* remainder */
147 nh
= (way
+ wah
) - ny
- 2 * c
->border
;
149 nh
= th
- 2 * c
->border
;
151 resize(c
, nx
, ny
, nw
, nh
, awesomeconf
->resize_hints
);
152 if(n
> nmaster
&& th
!= wah
)
153 ny
+= nh
+ 2 * c
->border
;
159 tile(Display
*disp
, awesome_config
*awesomeconf
)
161 _tile(disp
, awesomeconf
, True
);
165 tileleft(Display
*disp
, awesome_config
*awesomeconf
)
167 _tile(disp
, awesomeconf
, False
);
172 _bstack(Display
*disp
, awesome_config
*awesomeconf
, Bool portrait
)
174 int i
, n
, nx
, ny
, nw
, nh
, mw
, mh
, tw
, th
;
175 int wah
= get_windows_area_height(disp
, awesomeconf
->statusbar
);
176 int waw
= get_windows_area_width(disp
, awesomeconf
->statusbar
);
179 for(n
= 0, c
= clients
; c
; c
= c
->next
)
180 if(IS_TILED(c
, awesomeconf
->selected_tags
, awesomeconf
->ntags
))
184 mh
= (n
> nmaster
) ? (wah
* mwfact
) / nmaster
: wah
/ (n
> 0 ? n
: 1);
186 th
= (n
> nmaster
) ? (wah
* (1 - mwfact
)) / (portrait
? 1 : n
- nmaster
) : 0;
187 tw
= (n
> nmaster
) ? waw
/ (portrait
? n
- nmaster
: 1) : 0;
189 for(i
= 0, c
= clients
; c
; c
= c
->next
)
191 if(!IS_TILED(c
, awesomeconf
->selected_tags
, awesomeconf
->ntags
))
195 nx
= get_windows_area_x(awesomeconf
->statusbar
);
196 ny
= get_windows_area_y(awesomeconf
->statusbar
);
200 nw
= mw
- 2 * c
->border
;
201 nh
= mh
- 2 * c
->border
;
205 nx
+= (i
- nmaster
) * tw
;
207 nw
= tw
- 2 * c
->border
;
208 nh
= th
- 2 * c
->border
+ 1;
213 nw
= tw
- 2 * c
->border
;
214 if(th
> 2 * c
->border
)
216 ny
+= (i
- nmaster
) * th
;
217 nh
= th
- 2 * c
->border
;
219 nh
+= (n
> nmaster
) ? wah
- mh
- th
* (n
- nmaster
) : 0;
222 nh
= wah
- 2 * c
->border
;
224 resize(c
, nx
, ny
, nw
, nh
, False
);
230 bstack(Display
*disp
, awesome_config
*awesomeconf
)
232 _bstack(disp
, awesomeconf
, False
);
236 bstackportrait(Display
*disp
, awesome_config
*awesomeconf
)
238 _bstack(disp
, awesomeconf
, True
);