]> git.mdlowis.com Git - proto/labwc.git/commitdiff
rcxml: fix broken OSD layout with multiple <fields> entries
authortokyo4j <hrak1529@gmail.com>
Sat, 12 Apr 2025 11:51:02 +0000 (20:51 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 12 Apr 2025 20:27:41 +0000 (21:27 +0100)
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>.

src/config/rcxml.c

index c1b3f5b33c3776fc39765847b6613a10b3619391..cad132f856c7aa090def5524fb2c7bccbc17b714 100644 (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) {