rcxml: fix broken OSD layout with multiple <fields> entries

Before this commit, all <field> entries inside different <fields> entires
were inserted to the same list. Suppose we have following configuration:

  <windowSwitcher>
    <fields><field content="title" width="100%" /></fields>
  </windowSwitcher>
  <windowSwitcher>
    <fields><field content="identifier" width="100%" /></fields>
  </windowSwitcher>

In this case, both two <field> entries were inserted to
rc.window_switcher.fields, making the OSD content overflow.

This commit fixes by clearing rc.window_switcher.fields when the parser
encounters <windowSwitcher><fields>.
This commit is contained in:
tokyo4j 2025-04-12 20:51:02 +09:00 committed by Johan Malm
parent fcf230e692
commit 96a3a576a9

View file

@ -358,6 +358,16 @@ fill_window_rule(char *nodename, char *content, struct parser_state *state)
}
}
static void
clear_window_switcher_fields(void)
{
struct window_switcher_field *field, *field_tmp;
wl_list_for_each_safe(field, field_tmp, &rc.window_switcher.fields, link) {
wl_list_remove(&field->link);
osd_field_free(field);
}
}
static void
fill_window_switcher_field(char *nodename, char *content, struct parser_state *state)
{
@ -1381,6 +1391,7 @@ 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;
@ -2042,11 +2053,7 @@ rcxml_finish(void)
regions_destroy(NULL, &rc.regions);
struct window_switcher_field *field, *field_tmp;
wl_list_for_each_safe(field, field_tmp, &rc.window_switcher.fields, link) {
wl_list_remove(&field->link);
osd_field_free(field);
}
clear_window_switcher_fields();
struct window_rule *rule, *rule_tmp;
wl_list_for_each_safe(rule, rule_tmp, &rc.window_rules, link) {