4 * Copyright © 2008 Alex Cornejo <acornejo@gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "layouts/fair.h"
26 #include "common/util.h"
28 extern awesome_t globalconf
;
31 layout_fair(int screen
, const orientation_t orientation
)
33 int u_divisions
=1, v_divisions
= 1,
36 area_t geometry
, area
;
38 area
= screen_area_get(screen
,
39 &globalconf
.screens
[screen
].wiboxes
,
40 &globalconf
.screens
[screen
].padding
,
43 for(c
= globalconf
.clients
; c
; c
= c
->next
)
44 if(IS_TILED(c
, screen
))
49 while(u_divisions
* u_divisions
< n
)
52 v_divisions
= (u_divisions
* (u_divisions
- 1) >= n
) ? u_divisions
- 1 : u_divisions
;
54 for(c
= globalconf
.clients
; c
; c
= c
->next
)
55 if(IS_TILED(c
, screen
))
57 if (((orientation
== East
) && (n
> 2))
58 || ((orientation
== South
) && (n
<= 2)))
60 geometry
.width
= area
.width
/ u_divisions
;
61 geometry
.height
= area
.height
/ v_divisions
;
62 geometry
.x
= area
.x
+ u
* geometry
.width
;
63 geometry
.y
= area
.y
+ v
* geometry
.height
;
67 geometry
.width
= area
.width
/ v_divisions
;
68 geometry
.height
= area
.height
/ u_divisions
;
69 geometry
.x
= area
.x
+ v
* geometry
.width
;
70 geometry
.y
= area
.y
+ u
* geometry
.height
;
72 geometry
.width
-= 2 * c
->border
;
73 geometry
.height
-= 2 * c
->border
;
75 client_resize(c
, geometry
, c
->honorsizehints
);
77 if(++u
== u_divisions
)
80 if(++v
== v_divisions
- 1)
81 u_divisions
= u_divisions
- u_divisions
* v_divisions
+ n
;
88 layout_fairh(int screen
)
90 layout_fair(screen
, East
);
94 layout_fairv(int screen
)
96 layout_fair(screen
, South
);
99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80