From fa18f347e55daa447ac12d7b962c65723b9b8203 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Thu, 23 Dec 2021 05:37:57 +0100 Subject: [PATCH] config/rcxml: Allow multiple s inside of a Issue arises when using the default config from docs/rc.xml.all. Without this patch only the last action defined inside a will have an effect. Without a config or when defining the same multiple times with each containing only a single the issue does not exist. --- include/config/mousebind.h | 1 + src/config/mousebind.c | 14 ++++++++++++++ src/config/rcxml.c | 6 ++++++ 3 files changed, 21 insertions(+) diff --git a/include/config/mousebind.h b/include/config/mousebind.h index f01a8849..dc96315f 100644 --- a/include/config/mousebind.h +++ b/include/config/mousebind.h @@ -34,5 +34,6 @@ struct mousebind { enum mouse_event mousebind_event_from_str(const char *str); uint32_t mousebind_button_from_str(const char *str, uint32_t *modifiers); struct mousebind *mousebind_create(const char *context); +struct mousebind *mousebind_create_from(struct mousebind *from, const char *context); #endif /* __LABWC_MOUSEBIND_H */ diff --git a/src/config/mousebind.c b/src/config/mousebind.c index 0f4a0f58..c8e31c44 100644 --- a/src/config/mousebind.c +++ b/src/config/mousebind.c @@ -92,3 +92,17 @@ mousebind_create(const char *context) } return m; } + +struct mousebind * +mousebind_create_from(struct mousebind *from, const char *context) +{ + if (!from) { + wlr_log(WLR_ERROR, "invalid mousebind instance specified"); + return NULL; + } + struct mousebind *m = mousebind_create(context); + m->button = from->button; + m->modifiers = from->modifiers; + m->mouse_event = from->mouse_event; + return m; +} diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 00ec1bae..38cb8997 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -75,6 +75,8 @@ fill_mousebind(char *nodename, char *content) /* * Example of what we are parsing: * + * + * * * */ @@ -97,6 +99,10 @@ fill_mousebind(char *nodename, char *content) current_mousebind->mouse_event = mousebind_event_from_str(content); } else if (!strcmp(nodename, "name.action")) { + if (current_mousebind->action) { + current_mousebind = mousebind_create_from(current_mousebind, + current_mouse_context); + } current_mousebind->action = strdup(content); } else if (!strcmp(nodename, "command.action")) { current_mousebind->command = strdup(content);