From 5aa5eb9d6f1be0b279cace1e58d43470ed6a7124 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 17 Aug 2013 23:52:48 +0100 Subject: [PATCH] Ensure nodes within contracted nodes are unselected. --- desktop/treeview.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/desktop/treeview.c b/desktop/treeview.c index 2d2e68d3d..eb43517f4 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -1137,6 +1137,8 @@ static nserror treeview_node_contract_cb(treeview_node *n, void *ctx, assert(n != NULL); assert(n->type != TREE_NODE_ROOT); + n->flags &= ~TREE_NODE_SELECTED; + if ((n->flags & TREE_NODE_EXPANDED) == false) { /* Nothing to do. */ return NSERROR_OK; @@ -1157,6 +1159,7 @@ static nserror treeview_node_contract_cb(treeview_node *n, void *ctx, /* Exported interface, documented in treeview.h */ nserror treeview_node_contract(treeview *tree, treeview_node *node) { + bool selected; assert(node != NULL); if ((node->flags & TREE_NODE_EXPANDED) == false) { @@ -1165,6 +1168,8 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node) return NSERROR_OK; } + selected = node->flags & TREE_NODE_SELECTED; + /* Contract children. */ treeview_walk_internal(node, false, NULL, treeview_node_contract_cb, NULL); @@ -1172,6 +1177,9 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node) /* Contract node */ treeview_node_contract_cb(node, NULL, false, false); + if (selected) + node->flags |= TREE_NODE_SELECTED; + /* Inform front end of change in dimensions */ tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);