]> git.mdlowis.com Git - proto/labwc.git/commitdiff
config/rcxml: Allow multiple <action>s inside of a <mousebind>
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Thu, 23 Dec 2021 04:37:57 +0000 (05:37 +0100)
committerARDiDo <90479315+ARDiDo@users.noreply.github.com>
Thu, 23 Dec 2021 14:53:11 +0000 (09:53 -0500)
Issue arises when using the default config from docs/rc.xml.all.
Without this patch only the last action defined inside a <mousebind>
will have an effect.

Without a config or when defining the same <mousebind> multiple times
with each containing only a single <action> the issue does not exist.

include/config/mousebind.h
src/config/mousebind.c
src/config/rcxml.c

index f01a884933a7420003dfa689a329a479e2c8706a..dc96315f1c278c044c9d2f6dd00e66ae6353f906 100644 (file)
@@ -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 */
index 0f4a0f58fc7eb84deb2eb56a2dbad054c8cef014..c8e31c44ab7a04114a8349f77e9d1cf69dab669b 100644 (file)
@@ -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;
+}
index 00ec1bae1909b81ae2999ac8b9209c24d7a61d38..38cb89979c4284593a7e8d57a7724e7757fd8800 100644 (file)
@@ -75,6 +75,8 @@ fill_mousebind(char *nodename, char *content)
        /*
         * Example of what we are parsing:
         * <mousebind button="Left" action="DoubleClick">
+        *   <action name="Focus"/>
+        *   <action name="Raise"/>
         *   <action name="ToggleMaximize"/>
         * </mousebind>
         */
@@ -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);