Merge branch 'fix-reload-assignments' into next
This commit is contained in:
commit
355082a74c
|
@ -148,7 +148,7 @@ struct Ignore_Event {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct regex {
|
struct regex {
|
||||||
const char *pattern;
|
char *pattern;
|
||||||
pcre *regex;
|
pcre *regex;
|
||||||
pcre_extra *extra;
|
pcre_extra *extra;
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,4 +28,10 @@ void match_copy(Match *dest, Match *src);
|
||||||
*/
|
*/
|
||||||
bool match_matches_window(Match *match, i3Window *window);
|
bool match_matches_window(Match *match, i3Window *window);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frees the given match. It must not be used afterwards!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void match_free(Match *match);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,6 +17,12 @@
|
||||||
*/
|
*/
|
||||||
struct regex *regex_new(const char *pattern);
|
struct regex *regex_new(const char *pattern);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frees the given regular expression. It must not be used afterwards!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void regex_free(struct regex *regex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given regular expression matches the given input and returns
|
* Checks if the given regular expression matches the given input and returns
|
||||||
* true if it does. In either case, it logs the outcome using LOG(), so it will
|
* true if it does. In either case, it logs the outcome using LOG(), so it will
|
||||||
|
|
180
src/config.c
180
src/config.c
|
@ -257,112 +257,116 @@ static void parse_configuration(const char *override_configpath) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void load_configuration(xcb_connection_t *conn, const char *override_configpath, bool reload) {
|
void load_configuration(xcb_connection_t *conn, const char *override_configpath, bool reload) {
|
||||||
if (reload) {
|
if (reload) {
|
||||||
/* First ungrab the keys */
|
/* First ungrab the keys */
|
||||||
ungrab_all_keys(conn);
|
ungrab_all_keys(conn);
|
||||||
|
|
||||||
struct Mode *mode;
|
struct Mode *mode;
|
||||||
Binding *bind;
|
Binding *bind;
|
||||||
while (!SLIST_EMPTY(&modes)) {
|
while (!SLIST_EMPTY(&modes)) {
|
||||||
mode = SLIST_FIRST(&modes);
|
mode = SLIST_FIRST(&modes);
|
||||||
FREE(mode->name);
|
FREE(mode->name);
|
||||||
|
|
||||||
/* Clear the old binding list */
|
/* Clear the old binding list */
|
||||||
bindings = mode->bindings;
|
bindings = mode->bindings;
|
||||||
while (!TAILQ_EMPTY(bindings)) {
|
while (!TAILQ_EMPTY(bindings)) {
|
||||||
bind = TAILQ_FIRST(bindings);
|
bind = TAILQ_FIRST(bindings);
|
||||||
TAILQ_REMOVE(bindings, bind, bindings);
|
TAILQ_REMOVE(bindings, bind, bindings);
|
||||||
FREE(bind->translated_to);
|
FREE(bind->translated_to);
|
||||||
FREE(bind->command);
|
FREE(bind->command);
|
||||||
FREE(bind);
|
FREE(bind);
|
||||||
}
|
}
|
||||||
FREE(bindings);
|
FREE(bindings);
|
||||||
SLIST_REMOVE(&modes, mode, Mode, modes);
|
SLIST_REMOVE(&modes, mode, Mode, modes);
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
struct Assignment *assign;
|
|
||||||
while (!TAILQ_EMPTY(&assignments)) {
|
|
||||||
assign = TAILQ_FIRST(&assignments);
|
|
||||||
FREE(assign->windowclass_title);
|
|
||||||
TAILQ_REMOVE(&assignments, assign, assignments);
|
|
||||||
FREE(assign);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Clear workspace names */
|
|
||||||
#if 0
|
|
||||||
Workspace *ws;
|
|
||||||
TAILQ_FOREACH(ws, workspaces, workspaces)
|
|
||||||
workspace_set_name(ws, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SLIST_INIT(&modes);
|
struct Assignment *assign;
|
||||||
|
while (!TAILQ_EMPTY(&assignments)) {
|
||||||
|
assign = TAILQ_FIRST(&assignments);
|
||||||
|
if (assign->type == A_TO_WORKSPACE)
|
||||||
|
FREE(assign->dest.workspace);
|
||||||
|
else if (assign->type == A_TO_OUTPUT)
|
||||||
|
FREE(assign->dest.output);
|
||||||
|
else if (assign->type == A_COMMAND)
|
||||||
|
FREE(assign->dest.command);
|
||||||
|
match_free(&(assign->match));
|
||||||
|
TAILQ_REMOVE(&assignments, assign, assignments);
|
||||||
|
FREE(assign);
|
||||||
|
}
|
||||||
|
|
||||||
struct Mode *default_mode = scalloc(sizeof(struct Mode));
|
/* Clear workspace names */
|
||||||
default_mode->name = sstrdup("default");
|
#if 0
|
||||||
default_mode->bindings = scalloc(sizeof(struct bindings_head));
|
Workspace *ws;
|
||||||
TAILQ_INIT(default_mode->bindings);
|
TAILQ_FOREACH(ws, workspaces, workspaces)
|
||||||
SLIST_INSERT_HEAD(&modes, default_mode, modes);
|
workspace_set_name(ws, NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bindings = default_mode->bindings;
|
SLIST_INIT(&modes);
|
||||||
|
|
||||||
|
struct Mode *default_mode = scalloc(sizeof(struct Mode));
|
||||||
|
default_mode->name = sstrdup("default");
|
||||||
|
default_mode->bindings = scalloc(sizeof(struct bindings_head));
|
||||||
|
TAILQ_INIT(default_mode->bindings);
|
||||||
|
SLIST_INSERT_HEAD(&modes, default_mode, modes);
|
||||||
|
|
||||||
|
bindings = default_mode->bindings;
|
||||||
|
|
||||||
#define REQUIRED_OPTION(name) \
|
#define REQUIRED_OPTION(name) \
|
||||||
if (config.name == NULL) \
|
if (config.name == NULL) \
|
||||||
die("You did not specify required configuration option " #name "\n");
|
die("You did not specify required configuration option " #name "\n");
|
||||||
|
|
||||||
/* Clear the old config or initialize the data structure */
|
/* Clear the old config or initialize the data structure */
|
||||||
memset(&config, 0, sizeof(config));
|
memset(&config, 0, sizeof(config));
|
||||||
|
|
||||||
/* Initialize default colors */
|
/* Initialize default colors */
|
||||||
#define INIT_COLOR(x, cborder, cbackground, ctext) \
|
#define INIT_COLOR(x, cborder, cbackground, ctext) \
|
||||||
do { \
|
do { \
|
||||||
x.border = get_colorpixel(cborder); \
|
x.border = get_colorpixel(cborder); \
|
||||||
x.background = get_colorpixel(cbackground); \
|
x.background = get_colorpixel(cbackground); \
|
||||||
x.text = get_colorpixel(ctext); \
|
x.text = get_colorpixel(ctext); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
config.client.background = get_colorpixel("#000000");
|
config.client.background = get_colorpixel("#000000");
|
||||||
INIT_COLOR(config.client.focused, "#4c7899", "#285577", "#ffffff");
|
INIT_COLOR(config.client.focused, "#4c7899", "#285577", "#ffffff");
|
||||||
INIT_COLOR(config.client.focused_inactive, "#333333", "#5f676a", "#ffffff");
|
INIT_COLOR(config.client.focused_inactive, "#333333", "#5f676a", "#ffffff");
|
||||||
INIT_COLOR(config.client.unfocused, "#333333", "#222222", "#888888");
|
INIT_COLOR(config.client.unfocused, "#333333", "#222222", "#888888");
|
||||||
INIT_COLOR(config.client.urgent, "#2f343a", "#900000", "#ffffff");
|
INIT_COLOR(config.client.urgent, "#2f343a", "#900000", "#ffffff");
|
||||||
INIT_COLOR(config.bar.focused, "#4c7899", "#285577", "#ffffff");
|
INIT_COLOR(config.bar.focused, "#4c7899", "#285577", "#ffffff");
|
||||||
INIT_COLOR(config.bar.unfocused, "#333333", "#222222", "#888888");
|
INIT_COLOR(config.bar.unfocused, "#333333", "#222222", "#888888");
|
||||||
INIT_COLOR(config.bar.urgent, "#2f343a", "#900000", "#ffffff");
|
INIT_COLOR(config.bar.urgent, "#2f343a", "#900000", "#ffffff");
|
||||||
|
|
||||||
config.default_border = BS_NORMAL;
|
config.default_border = BS_NORMAL;
|
||||||
config.default_floating_border = BS_NORMAL;
|
config.default_floating_border = BS_NORMAL;
|
||||||
/* Set default_orientation to NO_ORIENTATION for auto orientation. */
|
/* Set default_orientation to NO_ORIENTATION for auto orientation. */
|
||||||
config.default_orientation = NO_ORIENTATION;
|
config.default_orientation = NO_ORIENTATION;
|
||||||
|
|
||||||
parse_configuration(override_configpath);
|
parse_configuration(override_configpath);
|
||||||
|
|
||||||
if (reload) {
|
if (reload) {
|
||||||
translate_keysyms();
|
translate_keysyms();
|
||||||
grab_all_keys(conn, false);
|
grab_all_keys(conn, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.font.id == 0) {
|
if (config.font.id == 0) {
|
||||||
ELOG("You did not specify required configuration option \"font\"\n");
|
ELOG("You did not specify required configuration option \"font\"\n");
|
||||||
config.font = load_font("fixed", true);
|
config.font = load_font("fixed", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Set an empty name for every workspace which got no name */
|
/* Set an empty name for every workspace which got no name */
|
||||||
Workspace *ws;
|
Workspace *ws;
|
||||||
TAILQ_FOREACH(ws, workspaces, workspaces) {
|
TAILQ_FOREACH(ws, workspaces, workspaces) {
|
||||||
if (ws->name != NULL) {
|
if (ws->name != NULL) {
|
||||||
/* If the font was not specified when the workspace name
|
/* If the font was not specified when the workspace name
|
||||||
* was loaded, we need to predict the text width now */
|
* was loaded, we need to predict the text width now */
|
||||||
if (ws->text_width == 0)
|
if (ws->text_width == 0)
|
||||||
ws->text_width = predict_text_width(global_conn,
|
ws->text_width = predict_text_width(global_conn,
|
||||||
config.font, ws->name, ws->name_len);
|
config.font, ws->name, ws->name_len);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
workspace_set_name(ws, NULL);
|
workspace_set_name(ws, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
20
src/match.c
20
src/match.c
|
@ -136,3 +136,23 @@ bool match_matches_window(Match *match, i3Window *window) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Frees the given match. It must not be used afterwards!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void match_free(Match *match) {
|
||||||
|
/* First step: free the regex fields / patterns */
|
||||||
|
regex_free(match->title);
|
||||||
|
regex_free(match->application);
|
||||||
|
regex_free(match->class);
|
||||||
|
regex_free(match->instance);
|
||||||
|
regex_free(match->mark);
|
||||||
|
|
||||||
|
/* Second step: free the regex helper struct itself */
|
||||||
|
FREE(match->title);
|
||||||
|
FREE(match->application);
|
||||||
|
FREE(match->class);
|
||||||
|
FREE(match->instance);
|
||||||
|
FREE(match->mark);
|
||||||
|
}
|
||||||
|
|
12
src/regex.c
12
src/regex.c
|
@ -49,6 +49,18 @@ struct regex *regex_new(const char *pattern) {
|
||||||
return re;
|
return re;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Frees the given regular expression. It must not be used afterwards!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void regex_free(struct regex *regex) {
|
||||||
|
if (!regex)
|
||||||
|
return;
|
||||||
|
FREE(regex->pattern);
|
||||||
|
FREE(regex->regex);
|
||||||
|
FREE(regex->extra);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checks if the given regular expression matches the given input and returns
|
* Checks if the given regular expression matches the given input and returns
|
||||||
* true if it does. In either case, it logs the outcome using LOG(), so it will
|
* true if it does. In either case, it logs the outcome using LOG(), so it will
|
||||||
|
|
Loading…
Reference in New Issue