summarylogtreecommitdiffstats
path: root/keybind_item.patch
blob: 64f212e7e1157275fbd9aecc79371bbfbc06e83e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
diff -ruw -X openbox-efc7efc/.gitignore openbox-efc7efc/openbox/menu.c openbox-efc7efc^/openbox/menu.c
--- openbox-efc7efc/openbox/menu.c	2014-12-06 19:20:47.000000000 +0200
+++ openbox-efc7efc^/openbox/menu.c	2014-12-06 18:46:06.000000000 +0200
@@ -116,6 +116,7 @@
     }
 
     g_assert(menu_parse_state.parent == NULL);
+    keyboard_rebind();
 }
 
 void menu_shutdown(gboolean reconfig)
@@ -282,6 +283,8 @@
     gboolean is_default = FALSE;
     gchar *icon;
     ObMenuEntry *e;
+    GList *keylist;
+    gchar *keystring, **keys, **key;
 
     if (state->parent) {
         /* Don't try to extract "icon" attribute if icons in user-defined
@@ -292,11 +295,22 @@
             xmlNodePtr c;
             GSList *acts = NULL;
 
+            keylist = NULL;
+            if (obt_xml_attr_string(node, "key", &keystring)) {
+                keys = g_strsplit(keystring, " ", 0);
+                for (key = keys; *key; ++key)
+                    keylist = g_list_append(keylist, *key);
+                }
             c = obt_xml_find_node(node->children, "action");
             while (c) {
                 ObActionsAct *action = actions_parse(c);
-                if (action)
+                if (action) {
+                    if (keylist) {
+                        actions_act_ref(action);
+                        keyboard_bind(keylist, action);
+                    }
                     acts = g_slist_append(acts, action);
+                }
                 c = obt_xml_find_node(c->next, "action");
             }
             e = menu_add_normal(state->parent, -1, label, acts, TRUE);