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 */ /* Layouts */
virtscreen->layouts = layout = p_new(Layout, 1); virtscreen->layouts = layout = p_new(Layout, 1);
if(cfg_size(cfg_layouts, "layout")) if(cfg_size(cfg_layouts, "layout"))
{
for(i = 0; i < cfg_size(cfg_layouts, "layout"); i++) for(i = 0; i < cfg_size(cfg_layouts, "layout"); i++)
{ {
cfgsectmp = cfg_getnsec(cfg_layouts, "layout", i); cfgsectmp = cfg_getnsec(cfg_layouts, "layout", i);
@ -408,7 +409,14 @@ config_parse_screen(cfg_t *cfg, int screen)
layout->image = a_strdup(cfg_getstr(cfgsectmp, "image")); layout->image = a_strdup(cfg_getstr(cfgsectmp, "image"));
if(i < cfg_size(cfg_layouts, "layout") - 1) 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 else
{ {

View File

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

View File

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