summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2014-10-20 15:39:34 +0200
committerMikael Magnusson <mikachu@gmail.com>2014-10-23 23:11:27 +0200
commitd6985fd99691dd552070563f8d05602f27da89f0 (patch)
tree7aee581b059544745c392d467e9ab90d3a1f4778
parent6273bf2e94a777760fee5346c290fb6672a0cb70 (diff)
Allow specifying several mousebinds in one go, like for keybinds
Also fixes minor indent error
-rw-r--r--openbox/config.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/openbox/config.c b/openbox/config.c
index 434791bf..898eeec1 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -567,6 +567,8 @@ static void parse_mouse(xmlNodePtr node, gpointer d)
nbut = obt_xml_find_node(n->children, "mousebind");
while (nbut) {
+ gchar **button, **buttons;
+
if (!obt_xml_attr_string(nbut, "button", &buttonstr))
goto next_nbut;
if (obt_xml_attr_contains(nbut, "action", "press"))
@@ -582,17 +584,26 @@ static void parse_mouse(xmlNodePtr node, gpointer d)
else
goto next_nbut;
+ buttons = g_strsplit(buttonstr, " ", 0);
nact = obt_xml_find_node(nbut->children, "action");
while (nact) {
ObActionsAct *action;
- if ((action = actions_parse(nact)))
- mouse_bind(buttonstr, cx, mact, action);
+ /* actions_parse() creates one ref to the action, but we need
+ * exactly one ref per binding we use it for. */
+ if ((action = actions_parse(nact))) {
+ for (button = buttons; *button; ++button) {
+ actions_act_ref(action);
+ mouse_bind(*button, cx, mact, action);
+ }
+ actions_act_unref(action);
+ }
nact = obt_xml_find_node(nact->next, "action");
}
- g_free(buttonstr);
+ g_strfreev(buttons);
+ g_free(buttonstr);
next_nbut:
- nbut = obt_xml_find_node(nbut->next, "mousebind");
+ nbut = obt_xml_find_node(nbut->next, "mousebind");
}
}
g_free(modcxstr);