change Layout linked list to by cycling

This commit is contained in:
Julien Danjou 2008-01-11 10:32:44 +01:00
parent 53f3a4aca7
commit 34309baa60
3 changed files with 21 additions and 4 deletions

View File

@ -395,6 +395,7 @@ config_parse_screen(cfg_t *cfg, int screen)
/* Layouts */
virtscreen->layouts = layout = p_new(Layout, 1);
if(cfg_size(cfg_layouts, "layout"))
{
for(i = 0; i < cfg_size(cfg_layouts, "layout"); i++)
{
cfgsectmp = cfg_getnsec(cfg_layouts, "layout", i);
@ -408,8 +409,15 @@ config_parse_screen(cfg_t *cfg, int screen)
layout->image = a_strdup(cfg_getstr(cfgsectmp, "image"));
if(i < cfg_size(cfg_layouts, "layout") - 1)
layout = layout->next = p_new(Layout, 1);
{
layout->next = p_new(Layout, 1);
layout->next->prev = layout;
layout = layout->next;
}
}
/* do cycling */
virtscreen->layouts->prev = layout;
}
else
{
warn("no default layout available\n");

View File

@ -243,11 +243,19 @@ uicb_tag_setlayout(int screen, char *arg)
curtags = get_current_tags(screen);
for(i = 0; l && l != curtags[0]->layout; i++, l = l->next);
p_delete(&curtags);
if(!l)
i = 0;
for(i = compute_new_value_from_arg(arg, (double) i),
l = globalconf.screens[screen].layouts; l && i > 0; i--)
l = l->next;
i = compute_new_value_from_arg(arg, (double) i);
if(i >= 0)
for(l = globalconf.screens[screen].layouts; l && i > 0; i--)
l = l->next;
else
for(l = globalconf.screens[screen].layouts; l && i < 0; i++)
l = l->prev;
if(!l)
l = globalconf.screens[screen].layouts;
}

View File

@ -31,6 +31,7 @@ struct Layout
{
char *image;
LayoutArrange *arrange;
Layout *prev;
Layout *next;
};