From aa04eab0117307dc1beb5e3cb20861cbd5368b0c Mon Sep 17 00:00:00 2001 From: Raphael Khaiat Date: Mon, 5 Jul 2010 00:43:33 +0200 Subject: [PATCH] Delete struct default_tag by using tag structure for default_layout feature --- src/config.c | 42 ++++++++++++++++++++---------------------- src/structs.h | 10 +--------- src/tag.c | 43 ++++++++++++++++--------------------------- 3 files changed, 37 insertions(+), 58 deletions(-) diff --git a/src/config.c b/src/config.c index 7800798..3e3254f 100644 --- a/src/config.c +++ b/src/config.c @@ -445,8 +445,9 @@ conf_layout_section(void) void conf_tag_section(void) { - int i, j, k, l = 0, m, n, sc, count; + int i, j, k, l = 0, m, n, sc, count, bar_pos; char *tmp; + char *position; struct conf_sec *sec, *def_tag, **tag, **mouse; struct opt_type *opt; @@ -465,32 +466,29 @@ conf_tag_section(void) def_tag = fetch_section_first(sec, "default_tag"); - conf.default_tag.name = fetch_opt_first(def_tag, "new tag", "name").str; - conf.default_tag.mwfact = fetch_opt_first(def_tag, "0.5", "mwfact").fnum; - conf.default_tag.nmaster = fetch_opt_first(def_tag, "1", "nmaster").num; - conf.default_tag.layout = fetch_opt_first(def_tag, "title_right", "layout").str; - conf.default_tag.resizehint = fetch_opt_first(def_tag, "false", "resizehint").bool; - conf.default_tag.infobar_position = fetch_opt_first(def_tag, "top", "infobar_position").str; - + position = fetch_opt_first(def_tag, "top", "infobar_position").str; + if(!strcmp(position, "none") + || !strcmp(position, "hide") + || !strcmp(position, "hidden")) + bar_pos = IB_Hide; + else if(!strcmp(position, "bottom") + || !strcmp(position, "down")) + bar_pos = IB_Bottom; + else + bar_pos = IB_Top; + /* If there is no tag in the conf or more than * MAXTAG (36) print an error and create only one. */ - Tag default_tag = { conf.default_tag.name, NULL, 0, 1, - conf.default_tag.mwfact, conf.default_tag.nmaster, - False, conf.default_tag.resizehint, False, False, - IB_Top, - layout_name_to_struct(conf.layout, conf.default_tag.layout, conf.nlayout, layout_list), + Tag default_tag = { fetch_opt_first(def_tag, "new tag", "name").str, NULL, 0, 1, + fetch_opt_first(def_tag, "0.5", "mwfact").fnum, + fetch_opt_first(def_tag, "1", "nmaster").num, + False, fetch_opt_first(def_tag, "false", "resizehint").bool, + False, False, bar_pos, + layout_name_to_struct(conf.layout, fetch_opt_first(def_tag, "title_right", "layout").str, conf.nlayout, layout_list), 0, NULL, 0 }; - if(!strcmp(conf.default_tag.infobar_position ,"none") - || !strcmp(conf.default_tag.infobar_position, "hide") - || !strcmp(conf.default_tag.infobar_position, "hidden")) - default_tag.barpos = IB_Hide; - else if(!strcmp(conf.default_tag.infobar_position, "bottom") - || !strcmp(conf.default_tag.infobar_position, "down")) - default_tag.barpos = IB_Bottom; - else - default_tag.barpos = IB_Top; + conf.default_tag = default_tag; /* Mouse button action on tag */ conf.mouse_tag_action[TagSel] = diff --git a/src/structs.h b/src/structs.h index 7c09110..8b11463 100644 --- a/src/structs.h +++ b/src/structs.h @@ -347,15 +347,7 @@ typedef struct Bool ignore_next_client_rules; Bool tagautohide; Bool tagnamecount; - struct - { - char *name; - float mwfact; - uint nmaster; - char *layout; - Bool resizehint; - char *infobar_position; - }default_tag; + Tag default_tag; uint pad; int status_timing; char *status_path; diff --git a/src/tag.c b/src/tag.c index 55c05e3..160a44c 100644 --- a/src/tag.c +++ b/src/tag.c @@ -479,31 +479,6 @@ tag_new(int s, char *name) { char * displayedName; - Tag t = { NULL, NULL, 0, 1, - conf.default_tag.mwfact, conf.default_tag.nmaster, - False, conf.default_tag.resizehint, False, False, IB_Top, - layout_name_to_struct(conf.layout, conf.default_tag.layout, conf.nlayout, layout_list), - 0, NULL, 0 }; - - if(!strcmp(conf.default_tag.infobar_position ,"none") - || !strcmp(conf.default_tag.infobar_position, "hide") - || !strcmp(conf.default_tag.infobar_position, "hidden")) - t.barpos = IB_Hide; - else if(!strcmp(conf.default_tag.infobar_position, "bottom") - || !strcmp(conf.default_tag.infobar_position, "down")) - t.barpos = IB_Bottom; - else - t.barpos = IB_Top; - - if(conf.ntag[s] + 1 > MAXTAG) - { - warnx("Too many tag: Can't create new tag"); - - return; - } - - ++conf.ntag[s]; - if((!name || strlen(name) == 0)) { if(conf.tagnamecount) @@ -517,9 +492,23 @@ tag_new(int s, char *name) else displayedName = name; - tags[s][conf.ntag[s]] = t; + Tag t = { displayedName, NULL, 0, 0, + conf.default_tag.mwfact, conf.default_tag.nmaster, + False, conf.default_tag.resizehint, False, False, + conf.default_tag.barpos, conf.default_tag.layout, + 0, NULL, 0 }; - tags[s][conf.ntag[s]].name = _strdup(displayedName); + if(conf.ntag[s] + 1 > MAXTAG) + { + warnx("Too many tag: Can't create new tag"); + + return; + } + + ++conf.ntag[s]; + + tags[s][conf.ntag[s]] = t; +/* tags[s][conf.ntag[s]].name = _strdup(displayedName);*/ infobar_update_taglist(s); infobar_draw(s);