diff --git a/include/osd.h b/include/osd.h index 806b88d4..971389d2 100644 --- a/include/osd.h +++ b/include/osd.h @@ -56,7 +56,6 @@ void osd_field_get_content(struct window_switcher_field *field, struct buf *buf, struct view *view); /* Used by rcxml.c when parsing the config */ -struct window_switcher_field *osd_field_create(void); void osd_field_arg_from_xml_node(struct window_switcher_field *field, const char *nodename, const char *content); bool osd_field_is_valid(struct window_switcher_field *field); diff --git a/src/config/rcxml.c b/src/config/rcxml.c index cddf8951..92683cbe 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -372,21 +372,29 @@ clear_window_switcher_fields(void) } static void -fill_window_switcher_field(char *nodename, char *content, struct parser_state *state) +fill_window_switcher_field(xmlNode *node) { - if (!strcasecmp(nodename, "field.fields.windowswitcher")) { - state->current_field = osd_field_create(); - wl_list_append(&rc.window_switcher.fields, &state->current_field->link); - return; - } + struct window_switcher_field *field = znew(*field); + wl_list_append(&rc.window_switcher.fields, &field->link); - string_truncate_at_pattern(nodename, ".field.fields.windowswitcher"); - if (!content) { - /* intentionally left empty */ - } else if (!state->current_field) { - wlr_log(WLR_ERROR, "no "); - } else { - osd_field_arg_from_xml_node(state->current_field, nodename, content); + xmlNode *child; + char *key, *content; + LAB_XML_FOR_EACH(node, child, key, content) { + osd_field_arg_from_xml_node(field, key, content); + } +} + +static void +fill_window_switcher_fields(xmlNode *node) +{ + clear_window_switcher_fields(); + + xmlNode *child; + char *key, *content; + LAB_XML_FOR_EACH(node, child, key, content) { + if (!strcasecmp(key, "field")) { + fill_window_switcher_field(child); + } } } @@ -1072,8 +1080,8 @@ entry(xmlNode *node, char *nodename, char *content, struct parser_state *state) fill_regions(node); return; } - if (state->in_window_switcher_field) { - fill_window_switcher_field(nodename, content, state); + if (!strcasecmp(nodename, "fields.windowSwitcher")) { + fill_window_switcher_fields(node); return; } if (state->in_window_rules) { @@ -1428,7 +1436,6 @@ xml_tree_walk(xmlNode *node, struct parser_state *state) continue; } if (!strcasecmp((char *)n->name, "fields")) { - clear_window_switcher_fields(); state->in_window_switcher_field = true; traverse(n, state); state->in_window_switcher_field = false; diff --git a/src/osd-field.c b/src/osd-field.c index 2885febe..0819e1e6 100644 --- a/src/osd-field.c +++ b/src/osd-field.c @@ -297,13 +297,6 @@ reset_format: buf_reset(&field_result); } -struct window_switcher_field * -osd_field_create(void) -{ - struct window_switcher_field *field = znew(*field); - return field; -} - void osd_field_arg_from_xml_node(struct window_switcher_field *field, const char *nodename, const char *content)