]> Dogcows Code - chaz/openbox/blobdiff - openbox/config.c
Parse multiple keys in one keybind
[chaz/openbox] / openbox / config.c
index 93ba3cb48fa169c0de52aa4dd31709c26738aba1..27316bbbe5825fc017bd92fd67bf6565a24f7913 100644 (file)
@@ -389,39 +389,44 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d)
 
 static void parse_key(xmlNodePtr node, GList *keylist)
 {
-    gchar *key;
+    gchar *keystring, **keys, **key;
     xmlNodePtr n;
     gboolean is_chroot = FALSE;
 
-    if (!obt_xml_attr_string(node, "key", &key))
+    if (!obt_xml_attr_string(node, "key", &keystring))
         return;
 
     obt_xml_attr_bool(node, "chroot", &is_chroot);
 
-    keylist = g_list_append(keylist, key);
+    keys = g_strsplit(keystring, " ", 0);
+    for (key = keys; *key; ++key) {
+        keylist = g_list_append(keylist, *key);
 
-    if ((n = obt_xml_find_node(node->children, "keybind"))) {
-        while (n) {
-            parse_key(n, keylist);
-            n = obt_xml_find_node(n->next, "keybind");
+        if ((n = obt_xml_find_node(node->children, "keybind"))) {
+            while (n) {
+                parse_key(n, keylist);
+                n = obt_xml_find_node(n->next, "keybind");
+            }
         }
-    }
-    else if ((n = obt_xml_find_node(node->children, "action"))) {
-        while (n) {
-            ObActionsAct *action;
-
-            action = actions_parse(n);
-            if (action)
-                keyboard_bind(keylist, action);
-            n = obt_xml_find_node(n->next, "action");
+        else if ((n = obt_xml_find_node(node->children, "action"))) {
+            while (n) {
+                ObActionsAct *action;
+
+                action = actions_parse(n);
+                if (action)
+                    keyboard_bind(keylist, action);
+                n = obt_xml_find_node(n->next, "action");
+            }
         }
-    }
 
-    if (is_chroot)
-        keyboard_chroot(keylist);
 
-    g_free(key);
-    keylist = g_list_delete_link(keylist, g_list_last(keylist));
+        if (is_chroot)
+            keyboard_chroot(keylist);
+        keylist = g_list_delete_link(keylist, g_list_last(keylist));
+    }
+
+    g_strfreev(keys);
+    g_free(keystring);
 }
 
 static void parse_keyboard(xmlNodePtr node, gpointer d)
@@ -491,9 +496,14 @@ static void parse_mouse(xmlNodePtr node, gpointer d)
         modcxstr = g_strdup(cxstr); /* make a copy to mutilate */
         while (frame_next_context_from_string(modcxstr, &cx)) {
             if (!cx) {
-                g_message(_("Invalid context \"%s\" in mouse binding"),
-                          cxstr);
-                break;
+                gchar *s = strchr(modcxstr, ' ');
+                if (s) {
+                    *s = '\0';
+                    g_message(_("Invalid context \"%s\" in mouse binding"),
+                              modcxstr);
+                    *s = ' ';
+                }
+                continue;
             }
 
             nbut = obt_xml_find_node(n->children, "mousebind");
@@ -521,8 +531,8 @@ static void parse_mouse(xmlNodePtr node, gpointer d)
                         mouse_bind(buttonstr, cx, mact, action);
                     nact = obt_xml_find_node(nact->next, "action");
                 }
-            next_nbut:
             g_free(buttonstr);
+            next_nbut:
             nbut = obt_xml_find_node(nbut->next, "mousebind");
             }
         }
This page took 0.02532 seconds and 4 git commands to generate.