luaa: change deprecate() with more useful info
[awesome.git] / layouts / fibonacci.c
blob577c1928247d2b737e1e75f5dd5cb3f8f042a7ce
1 /*
2 * fibonacci.c - fibonacci layout
4 * Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
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.
22 #include "screen.h"
23 #include "tag.h"
24 #include "client.h"
25 #include "layouts/fibonacci.h"
27 extern awesome_t globalconf;
29 static void
30 layout_fibonacci(int screen, int shape)
32 int n = 0, i = 0;
33 client_t *c;
34 area_t geometry, area;
35 geometry = area = screen_area_get(screen,
36 &globalconf.screens[screen].wiboxes,
37 &globalconf.screens[screen].padding,
38 true);
40 for(c = globalconf.clients; c; c = c->next)
41 if(IS_TILED(c, screen))
42 n++;
43 for(c = globalconf.clients; c; c = c->next)
44 if(IS_TILED(c, screen))
46 if((i % 2 && geometry.height / 2 > 2 * c->border)
47 || (!(i % 2) && geometry.width / 2 > 2 * c->border))
49 if(i < n - 1)
51 if(i % 2)
52 geometry.height /= 2;
53 else
54 geometry.width /= 2;
55 if((i % 4) == 2 && !shape)
56 geometry.x += geometry.width;
57 else if((i % 4) == 3 && !shape)
58 geometry.y += geometry.height;
60 if((i % 4) == 0)
62 if(shape)
63 geometry.y += geometry.height;
64 else
65 geometry.y -= geometry.height;
67 else if((i % 4) == 1)
68 geometry.x += geometry.width;
69 else if((i % 4) == 2)
70 geometry.y += geometry.height;
71 else if((i % 4) == 3)
73 if(shape)
74 geometry.x += geometry.width;
75 else
76 geometry.x -= geometry.width;
78 if(i == 0)
79 geometry.y = area.y;
80 i++;
82 geometry.width -= 2 * c->border;
83 geometry.height -= 2 * c->border;
84 client_resize(c, geometry, c->honorsizehints);
85 geometry.width += 2 * c->border;
86 geometry.height += 2 * c->border;
90 void
91 layout_spiral(int screen)
93 layout_fibonacci(screen, 0);
96 void
97 layout_dwindle(int screen)
99 layout_fibonacci(screen, 1);
102 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80