From 00721a15ea7945f05aa7ec4bb70f0f79b54f6e80 Mon Sep 17 00:00:00 2001 From: Alex Cornejo Date: Wed, 10 Sep 2008 18:04:52 -0400 Subject: [PATCH] layout: add fair layout Based on the original idea of Nathan Huesken, which was then implemented by Gwenhael Le Moine, I completed and corrected the layout. I added icons for the layout and modified the makefile and the aweseomerc.lua.in to include the fair layout. In the process I also decided to modify layoutgen.sh and tag.c, so that in the future new layouts can be added without touching tag.c. Signed-off-by: Julien Danjou --- CMakeLists.txt | 1 + awesomerc.lua.in | 2 + build-utils/layoutgen.sh | 6 +++ icons/layouts/fairh.png | Bin 0 -> 194 bytes icons/layouts/fairhw.png | Bin 0 -> 194 bytes icons/layouts/fairv.png | Bin 0 -> 201 bytes icons/layouts/fairvw.png | Bin 0 -> 201 bytes layouts/fair.c | 103 +++++++++++++++++++++++++++++++++++++++ layouts/fair.h | 31 ++++++++++++ tag.c | 6 --- 10 files changed, 143 insertions(+), 6 deletions(-) create mode 100644 icons/layouts/fairh.png create mode 100644 icons/layouts/fairhw.png create mode 100644 icons/layouts/fairv.png create mode 100644 icons/layouts/fairvw.png create mode 100644 layouts/fair.c create mode 100644 layouts/fair.h 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 0000000000000000000000000000000000000000..b4e289d6e7dc711098035859923a4aa556350ca9 GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0P3?wHke>@jRF%}28J29*~C-V}>VGHmHab;j= z1TsG~WlRJ~mjw9*GdMiEkp|)S$Ssku=CXLI5gE>Fl<{iyR+DaxtN(b;^Tv) c2W7?#Q5UwKdX~4(6sU*6)78&qol`;+0FA~n^#A|> literal 0 HcmV?d00001 diff --git a/icons/layouts/fairhw.png b/icons/layouts/fairhw.png new file mode 100644 index 0000000000000000000000000000000000000000..514d66d06c89d5cefa080d0ae23e091b308361f4 GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0P3?wHke>@jRF%}28J29*~C-V}>VGHmHaozqx z_5c6>x^ekTAnB4IzhDN3XE)M7oFs2|7lsa2Sq~tGv%n*=n1O*?7=#%aX3dcR3bL1Y z`ns~;;N%h$koqs*BnK4I@N{tu(Kw&{gP)aWMh`nr4Ua=p?FGZOMYB7LZJ3LhnIk?v eNP19a%n)^9`>AJn`%Hm)7(8A5T-G@yGywqorZr#y literal 0 HcmV?d00001 diff --git a/icons/layouts/fairv.png b/icons/layouts/fairv.png new file mode 100644 index 0000000000000000000000000000000000000000..e5aad70fd0dee93bf5987c968eaec04632271909 GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0P3?wHke>@jRF%}28J29*~C-V}>VGHmHaorvf z0AwZ}6I=z7E(!7rW^j0RBMrn!@^*J&=wOxg0CG4BJR*x37`TN&n2}-D90{Nxdx@v7 zEBg&jE-?Y~T?g)E1BLWGT^vI+&L{uiXXTmE!_HH~!^6t+rg=JJ*>m>9a_fNv3TdP%DF{tDnm{r-UW|=^-*L literal 0 HcmV?d00001 diff --git a/icons/layouts/fairvw.png b/icons/layouts/fairvw.png new file mode 100644 index 0000000000000000000000000000000000000000..f97ce56b2b1554834e7e5cf7bdc3ef9ed2553a62 GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0P3?wHke>@jRF%}28J29*~C-V}>VGHmHaow&_ z|NsC0gx?wRAnB4IzhDN3XE)M7oFs2|7lsa2Sq~tGv%n*=n1O*?7=#%aX3dcR3bL1Y z`ns~;;N%h$(7JhS( + * + * 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;