2007-09-12 14:29:51 +02:00
|
|
|
/*
|
|
|
|
* spiral.c - spiral layout
|
|
|
|
*
|
|
|
|
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
|
|
|
* Copyright © 2007 Jeroen Schot <schot@a-eskwadraat.nl>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-09-12 16:03:42 +02:00
|
|
|
#include "awesome.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
#include "layout.h"
|
|
|
|
#include "tag.h"
|
|
|
|
#include "spiral.h"
|
|
|
|
|
|
|
|
extern Client *clients; /* global client list */
|
|
|
|
|
|
|
|
static void
|
2007-09-16 01:35:44 +02:00
|
|
|
fibonacci(Display *disp, int screen, awesome_config *awesomeconf, int shape)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
int n, nx, ny, nh, nw, i;
|
|
|
|
Client *c;
|
|
|
|
|
2007-09-12 16:03:42 +02:00
|
|
|
nx = get_windows_area_x(awesomeconf->statusbar);
|
2007-09-05 20:15:00 +02:00
|
|
|
ny = 0;
|
2007-09-12 16:03:42 +02:00
|
|
|
nw = get_windows_area_width(disp, awesomeconf->statusbar);
|
|
|
|
nh = get_windows_area_height(disp, awesomeconf->statusbar);
|
2007-09-06 20:02:30 +02:00
|
|
|
for(n = 0, c = clients; c; c = c->next)
|
2007-09-16 12:23:07 +02:00
|
|
|
if(IS_TILED(c, screen, awesomeconf->selected_tags, awesomeconf->ntags))
|
2007-09-06 20:02:30 +02:00
|
|
|
n++;
|
2007-09-16 01:35:44 +02:00
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
for(i = 0, c = clients; c; c = c->next)
|
|
|
|
{
|
2007-09-16 12:23:07 +02:00
|
|
|
if(!IS_TILED(c, screen, awesomeconf->selected_tags, awesomeconf->ntags))
|
2007-09-16 01:35:44 +02:00
|
|
|
continue;
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
c->ismax = False;
|
|
|
|
if((i % 2 && nh / 2 > 2 * c->border)
|
|
|
|
|| (!(i % 2) && nw / 2 > 2 * c->border))
|
|
|
|
{
|
|
|
|
if(i < n - 1)
|
|
|
|
{
|
|
|
|
if(i % 2)
|
|
|
|
nh /= 2;
|
|
|
|
else
|
|
|
|
nw /= 2;
|
|
|
|
if((i % 4) == 2 && !shape)
|
|
|
|
ny += nh;
|
|
|
|
}
|
|
|
|
if((i % 4) == 0)
|
|
|
|
{
|
|
|
|
if(shape)
|
|
|
|
ny += nh;
|
|
|
|
else
|
|
|
|
ny -= nh;
|
|
|
|
}
|
|
|
|
else if((i % 4) == 1)
|
|
|
|
nx += nw;
|
|
|
|
else if((i % 4) == 2)
|
|
|
|
ny += nh;
|
|
|
|
else if((i % 4) == 3)
|
|
|
|
{
|
|
|
|
if(shape)
|
|
|
|
nx += nw;
|
|
|
|
else
|
|
|
|
nx -= nw;
|
|
|
|
}
|
|
|
|
if(i == 0)
|
2007-09-12 16:03:42 +02:00
|
|
|
ny = get_windows_area_y(awesomeconf->statusbar);
|
2007-09-05 20:15:00 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
resize(c, nx, ny, nw - 2 * c->border, nh - 2 * c->border, False);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2007-09-16 01:35:44 +02:00
|
|
|
dwindle(Display *disp, int screen, awesome_config *awesomeconf)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-09-16 01:35:44 +02:00
|
|
|
fibonacci(disp, screen, awesomeconf, 1);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-09-16 01:35:44 +02:00
|
|
|
spiral(Display *disp, int screen, awesome_config *awesomeconf)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-09-16 01:35:44 +02:00
|
|
|
fibonacci(disp, screen, awesomeconf, 0);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|