X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fkeytree.c;h=714fffda60bc6bbccdfe0bbd46e74f732865a73a;hb=2e8c9a13d4e188b538b14bd9a9d9cf31809400ed;hp=b26a4da7dac41cbe6e295cd9b915374f1137cb69;hpb=b6d2529acb6e31efbf8c7791e44905a1712da891;p=chaz%2Fopenbox diff --git a/openbox/keytree.c b/openbox/keytree.c index b26a4da7..714fffda 100644 --- a/openbox/keytree.c +++ b/openbox/keytree.c @@ -19,6 +19,7 @@ #include "keyboard.h" #include "translate.h" +#include "actions.h" #include void tree_destroy(KeyBindingTree *tree) @@ -35,7 +36,7 @@ void tree_destroy(KeyBindingTree *tree) g_free(it->data); g_list_free(tree->keylist); for (sit = tree->actions; sit != NULL; sit = sit->next) - action_unref(sit->data); + actions_act_unref(sit->data); g_slist_free(tree->actions); } g_free(tree); @@ -62,14 +63,18 @@ KeyBindingTree *tree_build(GList *keylist) g_strdup(kit->data)); /* deep copy */ ret->first_child = p; if (p != NULL) p->parent = ret; - if (!translate_key(it->data, &ret->state, &ret->key)) { - tree_destroy(ret); - return NULL; - } + translate_key(it->data, &ret->state, &ret->key); } return ret; } +void tree_rebind(KeyBindingTree *node) { + GList *it = g_list_last(node->keylist); + translate_key(it->data, &node->state, &node->key); + if (node->next_sibling) tree_rebind(node->next_sibling); + if (node->first_child) tree_rebind(node->first_child); +} + void tree_assimilate(KeyBindingTree *node) { KeyBindingTree *a, *b, *tmp, *last; @@ -133,16 +138,16 @@ KeyBindingTree *tree_find(KeyBindingTree *search, gboolean *conflict) gboolean tree_chroot(KeyBindingTree *tree, GList *keylist) { - if (keylist == NULL) { - tree->chroot = TRUE; - return TRUE; - } else { - guint key, state; - if (translate_key(keylist->data, &state, &key)) { - while (tree != NULL && !(tree->state == state && tree->key == key)) - tree = tree->next_sibling; - if (tree != NULL) - return tree_chroot(tree, keylist->next); + guint key, state; + if (translate_key(keylist->data, &state, &key)) { + while (tree != NULL && !(tree->state == state && tree->key == key)) + tree = tree->next_sibling; + if (tree != NULL) { + if (keylist->next == NULL) { + tree->chroot = TRUE; + return TRUE; + } else + return tree_chroot(tree->first_child, keylist->next); } } return FALSE;