From 274f1270e6f81ec4d366f05da2e184272b40b39e Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 6 Sep 2007 21:53:45 +0200 Subject: [PATCH] add taglayouts in jdwmconf as tag_layouts --- config.c | 50 +++++++++++++++++++++++++++----------------------- config.h | 2 ++ jdwm.c | 2 -- layout.c | 7 +------ tag.c | 3 +-- 5 files changed, 31 insertions(+), 33 deletions(-) diff --git a/config.c b/config.c index a0e8465c2..b1c7e57f9 100644 --- a/config.c +++ b/config.c @@ -153,6 +153,7 @@ uicb_reload(Display *disp, jdwm_config *jdwmconf, const char *arg __attribute__ p_delete(&jdwmconf->tags); p_delete(&jdwmconf->selected_tags); p_delete(&jdwmconf->layouts); + p_delete(&jdwmconf->tag_layouts); parse_config(disp, screen, &dc, jdwmconf); } @@ -192,28 +193,6 @@ parse_config(Display * disp, int scr, DC * drawcontext, jdwm_config *jdwmconf) eprint("error parsing configuration file at line %d: %s\n", config_error_line(&jdwmlibconf), config_error_text(&jdwmlibconf)); - /* tags */ - conftags = config_lookup(&jdwmlibconf, "jdwm.tags"); - - if(!conftags) - eprint("tags not found in configuration file\n"); - - jdwmconf->ntags = config_setting_length(conftags); - jdwmconf->tags = p_new(const char *, jdwmconf->ntags); - jdwmconf->selected_tags = p_new(Bool, jdwmconf->ntags); - jdwmconf->prev_selected_tags = p_new(Bool, jdwmconf->ntags); - - for(i = 0; (tmp = config_setting_get_string_elem(conftags, i)); i++) - { - jdwmconf->tags[i] = tmp; - jdwmconf->selected_tags[i] = False; - jdwmconf->prev_selected_tags[i] = False; - } - - /* select first tag by default */ - jdwmconf->selected_tags[0] = True; - jdwmconf->prev_selected_tags[0] = True; - /* layouts */ conflayouts = config_lookup(&jdwmlibconf, "jdwm.layouts"); @@ -228,13 +207,38 @@ parse_config(Display * disp, int scr, DC * drawcontext, jdwm_config *jdwmconf) jdwmconf->layouts[i].arrange = name_func_lookup(config_setting_get_string_elem(confsublayouts, 1), LayoutsList); if(!jdwmconf->layouts[i].arrange) - eprint("unknown layout in configuration file: %s", tmp); + eprint("unknown layout in configuration file\n"); } + jdwmconf->layouts[i].symbol = NULL; jdwmconf->layouts[i].arrange = NULL; /** \todo put this in set_default_layout */ jdwmconf->current_layout = jdwmconf->layouts; + /* tags */ + conftags = config_lookup(&jdwmlibconf, "jdwm.tags"); + + if(!conftags) + eprint("tags not found in configuration file\n"); + + jdwmconf->ntags = config_setting_length(conftags); + jdwmconf->tags = p_new(const char *, jdwmconf->ntags); + jdwmconf->selected_tags = p_new(Bool, jdwmconf->ntags); + jdwmconf->prev_selected_tags = p_new(Bool, jdwmconf->ntags); + jdwmconf->tag_layouts = p_new(Layout *, jdwmconf->ntags); + + for(i = 0; (tmp = config_setting_get_string_elem(conftags, i)); i++) + { + jdwmconf->tags[i] = tmp; + jdwmconf->selected_tags[i] = False; + jdwmconf->prev_selected_tags[i] = False; + /** \todo add support for default tag/layout in configuration file */ + jdwmconf->tag_layouts[i] = jdwmconf->layouts; + } + + /* select first tag by default */ + jdwmconf->selected_tags[0] = True; + jdwmconf->prev_selected_tags[0] = True; /* rules */ confrules = config_lookup(&jdwmlibconf, "jdwm.rules"); diff --git a/config.h b/config.h index 8690afd96..180c155a8 100644 --- a/config.h +++ b/config.h @@ -69,6 +69,8 @@ struct jdwm_config Layout *layouts; /** Number of layouts in *layouts */ int nlayouts; + /** Store layout for eatch tag */ + Layout **tag_layouts; /** Rules list */ Rule *rules; /** Number of rules in *rules */ diff --git a/jdwm.c b/jdwm.c index 9dd2811eb..74d6f87a9 100644 --- a/jdwm.c +++ b/jdwm.c @@ -32,7 +32,6 @@ Client *stack = NULL; Cursor cursor[CurLast]; DC dc; Window barwin; -Layout ** taglayouts; /* static */ @@ -97,7 +96,6 @@ cleanup(Display *disp, jdwm_config *jdwmconf) XFreeCursor(disp, cursor[CurMove]); XSetInputFocus(disp, PointerRoot, RevertToPointerRoot, CurrentTime); XSync(disp, False); - p_delete(&taglayouts); } static long diff --git a/layout.c b/layout.c index dd676926a..69bf10b74 100644 --- a/layout.c +++ b/layout.c @@ -18,7 +18,6 @@ int blw = 0; static char prop[128]; /* extern */ -extern Layout ** taglayouts; extern int wax, way, wah, waw; /* windowarea geometry */ extern Window barwin; extern Client *clients, *sel; /* global client list */ @@ -92,10 +91,6 @@ initlayouts(jdwm_config * jdwmconf) if(w > blw) blw = w; } - - taglayouts = p_new(Layout *, jdwmconf->ntags); - for(i = 0; i < jdwmconf->ntags; i++) - taglayouts[i] = jdwmconf->layouts; } void @@ -192,7 +187,7 @@ uicb_setlayout(Display *disp, jdwm_config * jdwmconf, const char *arg) for(j = 0; j < jdwmconf->ntags; j++) if (jdwmconf->selected_tags[j]) - taglayouts[j] = jdwmconf->current_layout; + jdwmconf->tag_layouts[j] = jdwmconf->current_layout; } void diff --git a/tag.c b/tag.c index 023952690..bc85c0654 100644 --- a/tag.c +++ b/tag.c @@ -10,7 +10,6 @@ #include "tag.h" extern Client *sel; /* global client list */ -extern Layout ** taglayouts; static Regs *regs = NULL; static char prop[512]; @@ -233,7 +232,7 @@ uicb_view(Display *disp, if(i >= 0 && i < jdwmconf->ntags) { jdwmconf->selected_tags[i] = True; - jdwmconf->current_layout = taglayouts[i]; + jdwmconf->current_layout = jdwmconf->tag_layouts[i]; } savejdwmprops(disp, jdwmconf); arrange(disp, jdwmconf);