diff --git a/config.c b/config.c index 60afd76a..dcf5de02 100644 --- a/config.c +++ b/config.c @@ -376,23 +376,22 @@ config_parse_screen(cfg_t *cfg, int screen) if((i = cfg_size(cfg_tags, "tag"))) for(--i; i >= 0; i--) { - tag = p_new(Tag, 1); cfgsectmp = cfg_getnsec(cfg_tags, "tag", i); - tag->name = a_strdup(cfg_title(cfgsectmp)); - tag->selected = False; - tag->was_selected = False; + tmp = cfg_getstr(cfgsectmp, "layout"); for(layout = virtscreen->layouts; - layout && layout->arrange != name_func_lookup(tmp, LayoutList); layout = layout->next); + layout && layout->arrange != name_func_lookup(tmp, LayoutList); + layout = layout->next); if(!layout) - tag->layout = virtscreen->layouts; - else - tag->layout = layout; - tag->mwfact = cfg_getfloat(cfgsectmp, "mwfact"); - tag->nmaster = cfg_getint(cfgsectmp, "nmaster"); - tag->ncol = cfg_getint(cfgsectmp, "ncol"); + layout = virtscreen->layouts; - tag_list_push(&virtscreen->tags, tag); + tag = tag_new(cfg_title(cfgsectmp), + layout, + cfg_getfloat(cfgsectmp, "mwfact"), + cfg_getint(cfgsectmp, "nmaster"), + cfg_getint(cfgsectmp, "ncol")); + + tag_push_to_screen(tag, screen); } else { diff --git a/tag.c b/tag.c index e4697c94..a98b0da2 100644 --- a/tag.c +++ b/tag.c @@ -32,6 +32,35 @@ extern AwesomeConf globalconf; +Tag * +tag_new(const char *name, Layout *layout, double mwfact, int nmaster, int ncol) +{ + Tag *tag; + + tag = p_new(Tag, 1); + tag->name = a_strdup(name); + tag->layout = layout; + tag->mwfact = mwfact; + tag->nmaster = nmaster; + tag->ncol = ncol; + + return tag; +} + +static void +tag_append_to_screen(Tag *tag, int screen) +{ + tag_list_append(&globalconf.screens[screen].tags, tag); + widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); +} + +void +tag_push_to_screen(Tag *tag, int screen) +{ + tag_list_push(&globalconf.screens[screen].tags, tag); + widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); +} + void tag_client(Client *c, Tag *t) { @@ -382,14 +411,8 @@ uicb_tag_create(int screen, char *arg) if(!a_strlen(arg)) return; - tag = p_new(Tag, 1); - tag->name = a_strdup(arg); - tag->layout = globalconf.screens[screen].layouts; - tag->mwfact = 0.5; - tag->nmaster = 1; - tag->ncol = 1; - tag_list_append(&globalconf.screens[screen].tags, tag); - widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); + tag = tag_new(arg, globalconf.screens[screen].layouts, 0.5, 1, 1); + tag_append_to_screen(tag, screen); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/tag.h b/tag.h index 6e992c83..57d605ba 100644 --- a/tag.h +++ b/tag.h @@ -27,7 +27,9 @@ /** Check if a client is tiled */ #define IS_TILED(client, screen) (client && !client->isfloating && client_isvisible(client, screen)) -Tag ** get_current_tags(int ); +Tag * tag_new(const char *, Layout *, double, int, int); +void tag_push_to_screen(Tag *, int); +Tag ** get_current_tags(int); void tag_client(Client *, Tag *); void untag_client(Client *, Tag *); Bool is_client_tagged(Client *, Tag *);