diff --git a/CMakeLists.txt b/CMakeLists.txt index 36323761..a4972825 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,7 @@ set(AWE_SRCS ${SOURCE_DIR}/layouts/fibonacci.c ${SOURCE_DIR}/layouts/floating.c ${SOURCE_DIR}/layouts/magnifier.c + ${SOURCE_DIR}/layouts/fair.c ${SOURCE_DIR}/layouts/max.c ${SOURCE_DIR}/layouts/tile.c ${SOURCE_DIR}/widgets/graph.c diff --git a/awesomerc.lua.in b/awesomerc.lua.in index d794487a..d8906f76 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -26,6 +26,8 @@ layouts = "tileleft", "tilebottom", "tiletop", + "fairh", + "fairv", "magnifier", "max", "spiral", diff --git a/build-utils/layoutgen.sh b/build-utils/layoutgen.sh index f0f42985..804ea725 100755 --- a/build-utils/layoutgen.sh +++ b/build-utils/layoutgen.sh @@ -2,6 +2,12 @@ top_srcdir="${1-.}" echo "/* This file is autogenerated by" `basename $0` "*/" echo +for file in ${top_srcdir}/layouts/*.h +do + shortname=`echo $file | cut -f2- -d/` + echo "#include \"${shortname}\"" +done +echo echo "const name_func_link_t LayoutList[] =" echo "{" for file in ${top_srcdir}/layouts/*.h diff --git a/icons/layouts/fairh.png b/icons/layouts/fairh.png new file mode 100644 index 00000000..b4e289d6 Binary files /dev/null and b/icons/layouts/fairh.png differ diff --git a/icons/layouts/fairhw.png b/icons/layouts/fairhw.png new file mode 100644 index 00000000..514d66d0 Binary files /dev/null and b/icons/layouts/fairhw.png differ diff --git a/icons/layouts/fairv.png b/icons/layouts/fairv.png new file mode 100644 index 00000000..e5aad70f Binary files /dev/null and b/icons/layouts/fairv.png differ diff --git a/icons/layouts/fairvw.png b/icons/layouts/fairvw.png new file mode 100644 index 00000000..f97ce56b Binary files /dev/null and b/icons/layouts/fairvw.png differ diff --git a/layouts/fair.c b/layouts/fair.c new file mode 100644 index 00000000..4ecebb4d --- /dev/null +++ b/layouts/fair.c @@ -0,0 +1,103 @@ +/* + * fair.c - fair layout + * + * Copyright © 2008 Alex Cornejo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "screen.h" +#include "tag.h" +#include "client.h" +#include "layouts/fair.h" +#include "common/util.h" + +extern awesome_t globalconf; + +typedef enum +{ + HORIZONTAL, + VERTICAL +} orientation_t; + +static void +layout_fair(int screen, const orientation_t orientation) +{ + int u_divisions=1, v_divisions = 1, + u = 0, v = 0, n = 0; + client_t *c; + area_t geometry, area; + + area = screen_area_get(&globalconf.screens[screen].geometry, + globalconf.screens[screen].statusbar, + &globalconf.screens[screen].padding); + + for(c = globalconf.clients ; c; c = c->next) + if(IS_TILED(c, screen)) + ++n; + + if(n > 0) + { + while(u_divisions * u_divisions < n) + ++u_divisions; + + v_divisions = (u_divisions * (u_divisions - 1) >= n) ? u_divisions - 1 : u_divisions; + + for(c = globalconf.clients; c; c = c->next) + if(IS_TILED(c, screen)) + { + if (orientation == HORIZONTAL) + { + geometry.width = area.width / u_divisions; + geometry.height = area.height / v_divisions; + geometry.x = area.x + u * geometry.width; + geometry.y = area.y + v * geometry.height; + } + else + { + geometry.width = area.width / v_divisions; + geometry.height = area.height / u_divisions; + geometry.x = area.x + v * geometry.width; + geometry.y = area.y + u * geometry.height; + } + geometry.width -= 2 * c->border; + geometry.height -= 2 * c->border; + + client_resize(c, geometry, c->honorsizehints); + + if(++u == u_divisions) + { + u = 0; + if(++v == v_divisions - 1) + u_divisions = u_divisions - u_divisions * v_divisions + n; + } + } + } +} + +void +layout_fairh(int screen) +{ + layout_fair(screen, HORIZONTAL); +} + +void +layout_fairv(int screen) +{ + layout_fair(screen, VERTICAL); +} + +// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/layouts/fair.h b/layouts/fair.h new file mode 100644 index 00000000..853dbc15 --- /dev/null +++ b/layouts/fair.h @@ -0,0 +1,31 @@ +/* + * fair.h - fair layout header + * + * Copyright © 2008 Alex Cornejo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef AWESOME_FAIR_H +#define AWESOME_FAIR_H + +#include "layout.h" + +layout_t layout_fairh; +layout_t layout_fairv; + +#endif +// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/tag.c b/tag.c index a892b6d9..cbe25d0e 100644 --- a/tag.c +++ b/tag.c @@ -25,12 +25,6 @@ #include "ewmh.h" #include "widget.h" -#include "layouts/magnifier.h" -#include "layouts/tile.h" -#include "layouts/max.h" -#include "layouts/floating.h" -#include "layouts/fibonacci.h" - #include "layoutgen.h" extern awesome_t globalconf;