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 strips
=1, cells
= 1,
34 strip
= 0, cell
= 0, n
= 0,
37 area_t geometry
, area
;
39 area
= screen_area_get(screen
,
40 &globalconf
.screens
[screen
].wiboxes
,
41 &globalconf
.screens
[screen
].padding
,
44 for(c
= globalconf
.clients
; c
; c
= c
->next
)
45 if(IS_TILED(c
, screen
))
50 while(cells
* cells
< n
)
53 strips
= (cells
* (cells
- 1) >= n
) ? cells
- 1 : cells
;
54 full_strips
= n
- strips
* (cells
- 1);
56 for(c
= globalconf
.clients
; c
; c
= c
->next
)
57 if(IS_TILED(c
, screen
))
59 if (((orientation
== East
) && (n
> 2))
60 || ((orientation
== South
) && (n
<= 2)))
62 geometry
.width
= area
.width
/ cells
;
63 geometry
.height
= area
.height
/ strips
;
64 geometry
.x
= area
.x
+ cell
* geometry
.width
;
65 geometry
.y
= area
.y
+ strip
* geometry
.height
;
69 geometry
.width
= area
.width
/ strips
;
70 geometry
.height
= area
.height
/ cells
;
71 geometry
.x
= area
.x
+ strip
* geometry
.width
;
72 geometry
.y
= area
.y
+ cell
* geometry
.height
;
74 geometry
.width
-= 2 * c
->border
;
75 geometry
.height
-= 2 * c
->border
;
77 client_resize(c
, geometry
, c
->honorsizehints
);
82 if(++strip
== full_strips
)
90 layout_fairh(int screen
)
92 layout_fair(screen
, East
);
96 layout_fairv(int screen
)
98 layout_fair(screen
, South
);
101 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80