From 3b0f41dc66da86aaad4f0343bbfb632c7bbfd0c7 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 2 Feb 2008 00:59:59 -0500 Subject: fix a crash from chroot of invalid keys, and make keybindings reload better since invalid(not translated) keybindings are allowed in the tree, the tree's structure may actually need to change when reconfiguring. actually, it could need to anyways. so when re-translating all the keybindings, actually rebuild the keybinding tree. also, make the chroot building code not fail when translate fails, to match the rest of the code and avoid segfaults with chroots on invalid keys. --- openbox/keytree.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'openbox/keytree.c') diff --git a/openbox/keytree.c b/openbox/keytree.c index 714fffda..56cc96d4 100644 --- a/openbox/keytree.c +++ b/openbox/keytree.c @@ -68,13 +68,6 @@ KeyBindingTree *tree_build(GList *keylist) 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; @@ -139,16 +132,15 @@ KeyBindingTree *tree_find(KeyBindingTree *search, gboolean *conflict) gboolean tree_chroot(KeyBindingTree *tree, GList *keylist) { 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); - } + 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; } -- cgit v1.2.3