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 <julien@danjou.info>
This commit is contained in:
parent
6690456668
commit
00721a15ea
|
@ -74,6 +74,7 @@ set(AWE_SRCS
|
||||||
${SOURCE_DIR}/layouts/fibonacci.c
|
${SOURCE_DIR}/layouts/fibonacci.c
|
||||||
${SOURCE_DIR}/layouts/floating.c
|
${SOURCE_DIR}/layouts/floating.c
|
||||||
${SOURCE_DIR}/layouts/magnifier.c
|
${SOURCE_DIR}/layouts/magnifier.c
|
||||||
|
${SOURCE_DIR}/layouts/fair.c
|
||||||
${SOURCE_DIR}/layouts/max.c
|
${SOURCE_DIR}/layouts/max.c
|
||||||
${SOURCE_DIR}/layouts/tile.c
|
${SOURCE_DIR}/layouts/tile.c
|
||||||
${SOURCE_DIR}/widgets/graph.c
|
${SOURCE_DIR}/widgets/graph.c
|
||||||
|
|
|
@ -26,6 +26,8 @@ layouts =
|
||||||
"tileleft",
|
"tileleft",
|
||||||
"tilebottom",
|
"tilebottom",
|
||||||
"tiletop",
|
"tiletop",
|
||||||
|
"fairh",
|
||||||
|
"fairv",
|
||||||
"magnifier",
|
"magnifier",
|
||||||
"max",
|
"max",
|
||||||
"spiral",
|
"spiral",
|
||||||
|
|
|
@ -2,6 +2,12 @@
|
||||||
top_srcdir="${1-.}"
|
top_srcdir="${1-.}"
|
||||||
echo "/* This file is autogenerated by" `basename $0` "*/"
|
echo "/* This file is autogenerated by" `basename $0` "*/"
|
||||||
echo
|
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 "const name_func_link_t LayoutList[] ="
|
||||||
echo "{"
|
echo "{"
|
||||||
for file in ${top_srcdir}/layouts/*.h
|
for file in ${top_srcdir}/layouts/*.h
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 194 B |
Binary file not shown.
After Width: | Height: | Size: 194 B |
Binary file not shown.
After Width: | Height: | Size: 201 B |
Binary file not shown.
After Width: | Height: | Size: 201 B |
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
* fair.c - fair layout
|
||||||
|
*
|
||||||
|
* Copyright © 2008 Alex Cornejo <acornejo@gmail.com>
|
||||||
|
*
|
||||||
|
* 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
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* fair.h - fair layout header
|
||||||
|
*
|
||||||
|
* Copyright © 2008 Alex Cornejo <acornejo@gmail.com>
|
||||||
|
*
|
||||||
|
* 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
|
6
tag.c
6
tag.c
|
@ -25,12 +25,6 @@
|
||||||
#include "ewmh.h"
|
#include "ewmh.h"
|
||||||
#include "widget.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"
|
#include "layoutgen.h"
|
||||||
|
|
||||||
extern awesome_t globalconf;
|
extern awesome_t globalconf;
|
||||||
|
|
Loading…
Reference in New Issue