These layouts tries to allocate the space "fairly" between (tiled) clients, giving an equal surface to each. 'fairhorizontal' add new clients horizontally, creating new rows as necessary; 'fairvertical' add new clients vertically, creating new columns as necessary. Based on a original idea of Nathan Huesken. Signed-off-by: Gwenhael Le Moine <[EMAIL PROTECTED]>
--- CMakeLists.txt | 1 + awesomerc.lua.in | 4 +- common/util.h | 9 ++- icons/layouts/fairhorizontal.png | Bin 0 -> 385 bytes icons/layouts/fairhorizontalw.png | Bin 0 -> 386 bytes icons/layouts/fairvertical.png | Bin 0 -> 391 bytes icons/layouts/fairverticalw.png | Bin 0 -> 396 bytes layouts/fair.c | 128 +++++++++++++++++++++++++++++++++++++ layouts/fair.h | 31 +++++++++ tag.c | 1 + 10 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 icons/layouts/fairhorizontal.png create mode 100644 icons/layouts/fairhorizontalw.png create mode 100644 icons/layouts/fairvertical.png create mode 100644 icons/layouts/fairverticalw.png create mode 100644 layouts/fair.c create mode 100644 layouts/fair.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d6c1fc8..2663f9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,7 @@ set(AWE_SRCS ${SOURCE_DIR}/common/xscreen.c ${SOURCE_DIR}/common/xutil.c ${SOURCE_DIR}/layouts/fibonacci.c + ${SOURCE_DIR}/layouts/fair.c ${SOURCE_DIR}/layouts/floating.c ${SOURCE_DIR}/layouts/magnifier.c ${SOURCE_DIR}/layouts/max.c diff --git a/awesomerc.lua.in b/awesomerc.lua.in index ff2d959..d3cce90 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -30,7 +30,9 @@ layouts = "max", "spiral", "dwindle", - "floating" + "floating", + "fairhorizontal", + "fairvertical", } -- Table of clients that should be set floating. The index may be either diff --git a/common/util.h b/common/util.h index 670a6ca..b11b795 100644 --- a/common/util.h +++ b/common/util.h @@ -35,7 +35,7 @@ #include "tokenize.h" -/** A list of possible position, not sex related */ +/** A list of possible positions, not sex related */ typedef enum { Off = 0, @@ -45,6 +45,13 @@ typedef enum Left } position_t; +/** A list of possible orientations, same remark */ +typedef enum +{ + Horizontal = 0, + Vertical, +} orientation_t; + /** Link a name to a function */ typedef struct { diff --git a/icons/layouts/fairhorizontal.png b/icons/layouts/fairhorizontal.png new file mode 100644 index 0000000000000000000000000000000000000000..dff1a79057cd364a62c9f9bc88de0dea4adf6119 GIT binary patch literal 385 [EMAIL PROTECTED](olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgfvPDXxH^Jzx~i-1CsC9V-A&iT2y zsd*&~&PAz-C8;S2<(VZJ3hti10pX2&;y^`rJY5_^DsH`<eUPigfX7An=KudsKWd1T ztX{Hv%jajyIu0K9xt(#gBS0dXyZ9#a50m3J;}q_ys~F$Eb}jbq!AqhIr`YFQVl-ZP z#F3|or|[EMAIL PROTECTED]<d{EsEnJ zw*cc|jt_1f95dV%3V|*OxX1I5fnkP!v-TeTijdhHKp_~|vEuIc4rVa#falw1`7$tx z0~d87nI}wfIpFiu+GXG0jLNMlf2XR<&H7w9C-Ojyb>IiBiN7}|[EMAIL PROTECTED]|y85}Sb4q9e E0Pm-VZ~y=R literal 0 HcmV?d00001 diff --git a/icons/layouts/fairhorizontalw.png b/icons/layouts/fairhorizontalw.png new file mode 100644 index 0000000000000000000000000000000000000000..3145e1bb41d23aed875fc976fee4062720a38d51 GIT binary patch literal 386 [EMAIL PROTECTED](olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|*pj^6U4S$Y z{B+)352QE?JR*x37`TN&[EMAIL PROTECTED]&jMt(D;3#QAWfI^Zbt`Q~9`MJ5N zc_j?aMX8A;sVNHOnI#zt?w-B@;f;LaKt*>wT^vIyZoR#Akgr)mz%_9B$N%*+-$^;m z>gd{P^!%+!$eFV-g&P9BG`%0~nfAn!KVdDulF}{4=(d`lp5a+vAH8tpTQ;xyuGF8$ z)w{Pd&6^S^`b6=C;*SegQtRE=xdIZJ=3H!K5_wT`Qlj?Vsmkv!92(y+JX*Kz&8o`k zb<zC`8$uJBUa)FR2w=2!67g7fV8wKGE`|k?pGs#iO*`26jrrR-Uq+xSA)rAgv)W!1 z%$}h6_F6M25J8~9e|gBJaEAbe$hQB^Pwwkxy+8lFaJ9pyJ&d#XDq1!E{oDXj<>~6@ [EMAIL PROTECTED]>_u|i+=zB literal 0 HcmV?d00001 diff --git a/icons/layouts/fairvertical.png b/icons/layouts/fairvertical.png new file mode 100644 index 0000000000000000000000000000000000000000..47d3b40392d63c663bc68378078d4cead76e06b4 GIT binary patch literal 391 [EMAIL PROTECTED](olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgfvPDXwcPQU%OGk`*pC9V-A&iT2y zsd*&~&PAz-C8;S2<(VZJ3hti10pX2&;[EMAIL PROTECTED]<9mv&Sz~d}^^Y40@|1PbK zqH}ibYm#p=2%Eh9MTp=-jTmo{^`Ce%mKXEN+-5$$^=&SX=R4DcYm=6EbNzTF+rns) z;KKYSMCHOe2gc1h%?<(_NsS^bfeZq3IGgtF;bGaxAaI09mcy#<o8QMjdzzUV6a-ut zRU8#MSQ`><25qqBVQGBeoltG;F2OnhsEt>Fa}k3=2h#=ypt7xsH{|Bsc|N;^b(Qmm z*cmZl$Mz>NdkU~U+4Jt^l>[EMAIL PROTECTED])qj)JeTCa<cg%ZR7}oe` aD--hq&24<[EMAIL PROTECTED](X@;f% literal 0 HcmV?d00001 diff --git a/icons/layouts/fairverticalw.png b/icons/layouts/fairverticalw.png new file mode 100644 index 0000000000000000000000000000000000000000..6e52f53b2736917ad310a7d76f1a96c1cc6e5b7c GIT binary patch literal 396 [EMAIL PROTECTED](olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|*pj^6U4S$Y z{B+)352QE?JR*x37`TN&[EMAIL PROTECTED]&jMt)=d7jyZtfI^Zbt`Q~9`MJ5N zc_j?aMX8A;sVNHOnI#zt?w-B@;f;LaKt<0zT^vIyZoQr9D0E0cfF*tE|Nj=IaVw{+ zIKm~8^WK*~$;|ewT1&2Wq3x7Cm&_Mjkylc3(~WU||[EMAIL PROTECTED])s+8Y}X@&SsnlK z4xF&=V9q$8z<KN1dXx1%wk%sX9GW~PaD3qr_YmNGr*_bHg&LEG0MmpA%m4E-nlNxW zF-%rqxxk>p!8l1|4xh54iiK;[EMAIL PROTECTED](VT#f`GmnN46PoP=_Ar+9GBCid1DhstuIyq9N zC;Tic+$*vE8Jn7;%!P?xuSq|dn)x8Ifg|S5uL%l*2|`Z_Ele4WSCvk<%l!DKxrJQ1 bxJR76$L8EK{GPF(aA)vz^>bP0l+XkK2P}bW literal 0 HcmV?d00001 diff --git a/layouts/fair.c b/layouts/fair.c new file mode 100644 index 0000000..c143149 --- /dev/null +++ b/layouts/fair.c @@ -0,0 +1,128 @@ +/* + * fair.c - fair layout + * + * Copyright © 2008 Gwenhael Le Moine <[EMAIL PROTECTED]> + * + * 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; + +static void +_fair(int screen, const orientation_t orientation) +{ + int x_divisions = 1, y_divisions = 1, + x_divisions_last_line, y_divisions_last_column, + x = 0, y = 0, n = 0; + client_t *c; + area_t geometry, area; + + geometry = 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 ) { + if( orientation == Horizontal ) { + while( x_divisions * x_divisions < n ) + ++x_divisions; + + y_divisions = ( x_divisions * ( x_divisions - 1 ) >= n ) ? + x_divisions - 1 : + x_divisions; + + x_divisions_last_line = n - ( x_divisions * ( y_divisions - 1 ) ); + + for( c = globalconf.clients ; c ; c = c->next ) { + if( IS_TILED(c, screen) ) { + geometry.height = ( area.height / y_divisions ) - ( 2 * c->border ); + if( ( ( y + 1 ) == y_divisions ) && ( x_divisions_last_line ) ) + geometry.width = ( area.width / x_divisions_last_line ) - ( 2 * c->border ); + else + geometry.width = ( area.width / x_divisions ) - ( 2 * c->border ); + + geometry.x = area.x + geometry.width * x; + geometry.y = area.y + geometry.height * y; + + client_resize( c, geometry, c->honorsizehints ); + + if( x == x_divisions - 1 ) { + x = 0; + ++y; + } + else + ++x; + } + } + } + else { + while( y_divisions * y_divisions < n ) + ++y_divisions; + + x_divisions = ( y_divisions * ( y_divisions - 1 ) >= n ) ? + y_divisions - 1 : + y_divisions; + + y_divisions_last_column = n - ( ( x_divisions - 1 ) * y_divisions ); + + for( c = globalconf.clients ; c ; c = c->next ) { + if( IS_TILED(c, screen) ) { + geometry.width = ( area.width / x_divisions ) - ( 2 * c->border ); + + if( ( ( x + 1 ) == x_divisions ) && ( y_divisions_last_column ) ) + geometry.height = ( area.height / y_divisions_last_column ) - ( 2 * c->border ); + else + geometry.height = ( area.height / y_divisions ) - ( 2 * c->border ); + + geometry.x = area.x + geometry.width * x; + geometry.y = area.y + geometry.height * y; + + client_resize( c, geometry, c->honorsizehints ); + + if( y == y_divisions - 1 ) { + y = 0; + ++x; + } + else + ++y; + } + } + } + } +} + +void +layout_fairhorizontal(int screen) +{ + _fair(screen, Horizontal); +} + +void +layout_fairvertical(int screen) +{ + _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 0000000..736e88f --- /dev/null +++ b/layouts/fair.h @@ -0,0 +1,31 @@ +/* + * fair.h - fair layout header + * + * Copyright © 2008 Gwenhael Le Moine <[EMAIL PROTECTED]> + * + * 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_fairhorizontal; +layout_t layout_fairvertical; + +#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 a892b6d..d523c39 100644 --- a/tag.c +++ b/tag.c @@ -30,6 +30,7 @@ #include "layouts/max.h" #include "layouts/floating.h" #include "layouts/fibonacci.h" +#include "layouts/fair.h" #include "layoutgen.h" -- 1.6.0.1 -- To unsubscribe, send mail to [EMAIL PROTECTED]