stop making awesomelibconf global and store screen number in awesome_configs
we strdup elems and p_delete them in cleanup
This commit is contained in:
parent
2222164c27
commit
c3bb58f47a
14
awesome.c
14
awesome.c
|
@ -56,7 +56,7 @@ static Bool readin = True, running = True;
|
||||||
static void
|
static void
|
||||||
cleanup(Display *disp, DC *drawcontext, awesome_config *awesomeconf)
|
cleanup(Display *disp, DC *drawcontext, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
int screen;
|
int screen, i;
|
||||||
|
|
||||||
close(STDIN_FILENO);
|
close(STDIN_FILENO);
|
||||||
|
|
||||||
|
@ -81,6 +81,18 @@ cleanup(Display *disp, DC *drawcontext, awesome_config *awesomeconf)
|
||||||
XFreeCursor(disp, drawcontext[screen].cursor[CurNormal]);
|
XFreeCursor(disp, drawcontext[screen].cursor[CurNormal]);
|
||||||
XFreeCursor(disp, drawcontext[screen].cursor[CurResize]);
|
XFreeCursor(disp, drawcontext[screen].cursor[CurResize]);
|
||||||
XFreeCursor(disp, drawcontext[screen].cursor[CurMove]);
|
XFreeCursor(disp, drawcontext[screen].cursor[CurMove]);
|
||||||
|
|
||||||
|
for(i = 0; i < awesomeconf[screen].ntags; i++)
|
||||||
|
p_delete(&awesomeconf[screen].tags[i]);
|
||||||
|
for(i = 0; i < awesomeconf[screen].nkeys; i++)
|
||||||
|
p_delete(&awesomeconf[screen].keys[i].arg);
|
||||||
|
for(i = 0; i < awesomeconf[screen].nlayouts; i++)
|
||||||
|
p_delete(&awesomeconf[screen].layouts[i].symbol);
|
||||||
|
for(i = 0; i < awesomeconf[screen].nrules; i++)
|
||||||
|
{
|
||||||
|
p_delete(&awesomeconf[screen].rules[i].prop);
|
||||||
|
p_delete(&awesomeconf[screen].rules[i].tags);
|
||||||
|
}
|
||||||
p_delete(&awesomeconf[screen].tags);
|
p_delete(&awesomeconf[screen].tags);
|
||||||
p_delete(&awesomeconf[screen].selected_tags);
|
p_delete(&awesomeconf[screen].selected_tags);
|
||||||
p_delete(&awesomeconf[screen].prev_selected_tags);
|
p_delete(&awesomeconf[screen].prev_selected_tags);
|
||||||
|
|
24
config.c
24
config.c
|
@ -37,14 +37,10 @@
|
||||||
#include "layouts/spiral.h"
|
#include "layouts/spiral.h"
|
||||||
#include "layouts/floating.h"
|
#include "layouts/floating.h"
|
||||||
|
|
||||||
/* static */
|
|
||||||
static void initfont(const char *, Display *, DC *);
|
static void initfont(const char *, Display *, DC *);
|
||||||
static unsigned long initcolor(const char *colstr, Display *, int);
|
static unsigned long initcolor(const char *, Display *, int);
|
||||||
static unsigned int get_numlockmask(Display *);
|
static unsigned int get_numlockmask(Display *);
|
||||||
|
|
||||||
/** Main configuration object for parsing*/
|
|
||||||
config_t awesomelibconf;
|
|
||||||
|
|
||||||
/** Link a name to a function */
|
/** Link a name to a function */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -176,6 +172,8 @@ set_default_config(awesome_config *awesomeconf)
|
||||||
void
|
void
|
||||||
parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomeconf)
|
parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
|
/* Main configuration object for parsing*/
|
||||||
|
config_t awesomelibconf;
|
||||||
config_setting_t *conftags;
|
config_setting_t *conftags;
|
||||||
config_setting_t *conflayouts, *confsublayouts;
|
config_setting_t *conflayouts, *confsublayouts;
|
||||||
config_setting_t *confrules, *confsubrules;
|
config_setting_t *confrules, *confsubrules;
|
||||||
|
@ -196,6 +194,9 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
||||||
|
|
||||||
config_init(&awesomelibconf);
|
config_init(&awesomelibconf);
|
||||||
|
|
||||||
|
/* set screen */
|
||||||
|
awesomeconf->screen = scr;
|
||||||
|
|
||||||
if(config_read_file(&awesomelibconf, confpath) == CONFIG_FALSE)
|
if(config_read_file(&awesomelibconf, confpath) == CONFIG_FALSE)
|
||||||
eprint("awesome: error parsing configuration file at line %d: %s\n",
|
eprint("awesome: error parsing configuration file at line %d: %s\n",
|
||||||
config_error_line(&awesomelibconf), config_error_text(&awesomelibconf));
|
config_error_line(&awesomelibconf), config_error_text(&awesomelibconf));
|
||||||
|
@ -223,7 +224,7 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
||||||
awesomeconf->layouts[i].symbol = NULL;
|
awesomeconf->layouts[i].symbol = NULL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
awesomeconf->layouts[i].symbol = config_setting_get_string_elem(confsublayouts, 0);
|
awesomeconf->layouts[i].symbol = a_strdup(config_setting_get_string_elem(confsublayouts, 0));
|
||||||
|
|
||||||
j = textw(drawcontext->font.set, drawcontext->font.xfont, awesomeconf->layouts[i].symbol, drawcontext->font.height);
|
j = textw(drawcontext->font.set, drawcontext->font.xfont, awesomeconf->layouts[i].symbol, drawcontext->font.height);
|
||||||
if(j > awesomeconf->statusbar.width)
|
if(j > awesomeconf->statusbar.width)
|
||||||
|
@ -245,14 +246,14 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
||||||
if(!conftags)
|
if(!conftags)
|
||||||
eprint("awesome: fatal: no tags found in configuration file\n");
|
eprint("awesome: fatal: no tags found in configuration file\n");
|
||||||
awesomeconf->ntags = config_setting_length(conftags);
|
awesomeconf->ntags = config_setting_length(conftags);
|
||||||
awesomeconf->tags = p_new(const char *, awesomeconf->ntags);
|
awesomeconf->tags = p_new(char *, awesomeconf->ntags);
|
||||||
awesomeconf->selected_tags = p_new(Bool, awesomeconf->ntags);
|
awesomeconf->selected_tags = p_new(Bool, awesomeconf->ntags);
|
||||||
awesomeconf->prev_selected_tags = p_new(Bool, awesomeconf->ntags);
|
awesomeconf->prev_selected_tags = p_new(Bool, awesomeconf->ntags);
|
||||||
awesomeconf->tag_layouts = p_new(Layout *, awesomeconf->ntags);
|
awesomeconf->tag_layouts = p_new(Layout *, awesomeconf->ntags);
|
||||||
|
|
||||||
for(i = 0; (tmp = config_setting_get_string_elem(conftags, i)); i++)
|
for(i = 0; (tmp = config_setting_get_string_elem(conftags, i)); i++)
|
||||||
{
|
{
|
||||||
awesomeconf->tags[i] = tmp;
|
awesomeconf->tags[i] = a_strdup(tmp);
|
||||||
awesomeconf->selected_tags[i] = False;
|
awesomeconf->selected_tags[i] = False;
|
||||||
awesomeconf->prev_selected_tags[i] = False;
|
awesomeconf->prev_selected_tags[i] = False;
|
||||||
/** \todo add support for default tag/layout in configuration file */
|
/** \todo add support for default tag/layout in configuration file */
|
||||||
|
@ -274,8 +275,8 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
||||||
awesomeconf->rules = p_new(Rule, awesomeconf->nrules);
|
awesomeconf->rules = p_new(Rule, awesomeconf->nrules);
|
||||||
for(i = 0; (confsubrules = config_setting_get_elem(confrules, i)); i++)
|
for(i = 0; (confsubrules = config_setting_get_elem(confrules, i)); i++)
|
||||||
{
|
{
|
||||||
awesomeconf->rules[i].prop = config_setting_get_string(config_setting_get_member(confsubrules, "name"));
|
awesomeconf->rules[i].prop = a_strdup(config_setting_get_string(config_setting_get_member(confsubrules, "name")));
|
||||||
awesomeconf->rules[i].tags = config_setting_get_string(config_setting_get_member(confsubrules, "tags"));
|
awesomeconf->rules[i].tags = a_strdup(config_setting_get_string(config_setting_get_member(confsubrules, "tags")));
|
||||||
if(awesomeconf->rules[i].tags && !strlen(awesomeconf->rules[i].tags))
|
if(awesomeconf->rules[i].tags && !strlen(awesomeconf->rules[i].tags))
|
||||||
awesomeconf->rules[i].tags = NULL;
|
awesomeconf->rules[i].tags = NULL;
|
||||||
awesomeconf->rules[i].isfloating =
|
awesomeconf->rules[i].isfloating =
|
||||||
|
@ -308,7 +309,7 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
||||||
awesomeconf->keys[i].keysym = XStringToKeysym(config_setting_get_string_elem(confsubkeys, 1));
|
awesomeconf->keys[i].keysym = XStringToKeysym(config_setting_get_string_elem(confsubkeys, 1));
|
||||||
awesomeconf->keys[i].func =
|
awesomeconf->keys[i].func =
|
||||||
name_func_lookup(config_setting_get_string_elem(confsubkeys, 2), KeyfuncList);
|
name_func_lookup(config_setting_get_string_elem(confsubkeys, 2), KeyfuncList);
|
||||||
awesomeconf->keys[i].arg = config_setting_get_string_elem(confsubkeys, 3);
|
awesomeconf->keys[i].arg = a_strdup(config_setting_get_string_elem(confsubkeys, 3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,6 +371,7 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
||||||
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_fg_color");
|
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_fg_color");
|
||||||
drawcontext->sel[ColFG] = initcolor(tmp ? tmp : "#ffffff", disp, scr);
|
drawcontext->sel[ColFG] = initcolor(tmp ? tmp : "#ffffff", disp, scr);
|
||||||
|
|
||||||
|
config_destroy(&awesomelibconf);
|
||||||
p_delete(&confpath);
|
p_delete(&confpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
config.h
14
config.h
|
@ -55,8 +55,8 @@ typedef struct
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const char *prop;
|
char *prop;
|
||||||
const char *tags;
|
char *tags;
|
||||||
Bool isfloating;
|
Bool isfloating;
|
||||||
} Rule;
|
} Rule;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ typedef struct awesome_config awesome_config;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const char *symbol;
|
char *symbol;
|
||||||
void (*arrange) (Display *, int, awesome_config *);
|
void (*arrange) (Display *, int, awesome_config *);
|
||||||
} Layout;
|
} Layout;
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ typedef struct
|
||||||
{
|
{
|
||||||
unsigned long mod;
|
unsigned long mod;
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
void (*func) (Display *, int, DC *, awesome_config *, const char *);
|
void (*func) (Display *, int, DC *, awesome_config *, char *);
|
||||||
const char *arg;
|
char *arg;
|
||||||
} Key;
|
} Key;
|
||||||
|
|
||||||
/** Status bar */
|
/** Status bar */
|
||||||
|
@ -96,8 +96,10 @@ typedef struct
|
||||||
/** Main configuration structure */
|
/** Main configuration structure */
|
||||||
struct awesome_config
|
struct awesome_config
|
||||||
{
|
{
|
||||||
|
/** Config screen number */
|
||||||
|
int screen;
|
||||||
/** Tag list */
|
/** Tag list */
|
||||||
const char **tags;
|
char **tags;
|
||||||
/** Selected tags */
|
/** Selected tags */
|
||||||
Bool *selected_tags;
|
Bool *selected_tags;
|
||||||
/* Previously selected tags */
|
/* Previously selected tags */
|
||||||
|
|
Loading…
Reference in New Issue