]> git.mdlowis.com Git - proto/labwc.git/commitdiff
rcxml: fix broken titlebar layout with multiple <layout> entries
authortokyo4j <hrak1529@gmail.com>
Sat, 12 Apr 2025 11:31:04 +0000 (20:31 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 12 Apr 2025 20:27:41 +0000 (21:27 +0100)
Before this commit, when we have multiple <theme><titlebar><layout>
entries like below, duplicated button types can be inserted to
rc.title_buttons_{left,right} and the button could go outside of the
window:
    <theme>
      <titlebar><layout>icon:iconify,max,close</layout></titlebar>
      <titlebar><layout>icon:iconify,max,close</layout></titlebar>
    </theme>

This commit fixes by clearing those lists when the parser encounters
<theme><titlebar><layout>.

src/config/rcxml.c

index 419e8daa3b93698146e960096e7a5f8b4b857eac..c1b3f5b33c3776fc39765847b6613a10b3619391 100644 (file)
@@ -201,9 +201,26 @@ fill_section(const char *content, struct wl_list *list, uint32_t *found_buttons)
        g_strfreev(identifiers);
 }
 
+static void
+clear_title_layout(void)
+{
+       struct title_button *button, *button_tmp;
+       wl_list_for_each_safe(button, button_tmp, &rc.title_buttons_left, link) {
+               wl_list_remove(&button->link);
+               zfree(button);
+       }
+       wl_list_for_each_safe(button, button_tmp, &rc.title_buttons_right, link) {
+               wl_list_remove(&button->link);
+               zfree(button);
+       }
+       rc.title_layout_loaded = false;
+}
+
 static void
 fill_title_layout(char *content)
 {
+       clear_title_layout();
+
        struct wl_list *sections[] = {
                &rc.title_buttons_left,
                &rc.title_buttons_right,
@@ -1978,15 +1995,7 @@ rcxml_finish(void)
        zfree(rc.workspace_config.prefix);
        zfree(rc.tablet.output_name);
 
-       struct title_button *p, *p_tmp;
-       wl_list_for_each_safe(p, p_tmp, &rc.title_buttons_left, link) {
-               wl_list_remove(&p->link);
-               zfree(p);
-       }
-       wl_list_for_each_safe(p, p_tmp, &rc.title_buttons_right, link) {
-               wl_list_remove(&p->link);
-               zfree(p);
-       }
+       clear_title_layout();
 
        struct usable_area_override *area, *area_tmp;
        wl_list_for_each_safe(area, area_tmp, &rc.usable_area_overrides, link) {