diff --git a/src/util.c b/src/util.c index 2c9ea0c..58d4ced 100644 --- a/src/util.c +++ b/src/util.c @@ -518,8 +518,14 @@ TreeNode* wm_treenode_remove_client(Wm *wm, TreeNode *root, Client *client) if (node->parent == NULL) { // parent is root node DEBUG_PRINT("parent is root node!\n"); + + TreeNode old_root = *client->ws->tree; + sibling_node->parent = NULL; - client->ws->tree = sibling_node; + *client->ws->tree = *sibling_node; + + wm_nodearray_free(old_root.children); + free(sibling_node); client->ws->tree->pos = (Rect) { .x = wm->config.border_width, .y = wm->config.border_width + dock_y , @@ -528,6 +534,9 @@ TreeNode* wm_treenode_remove_client(Wm *wm, TreeNode *root, Client *client) }; assert(client->ws->tree->children->size == 2); + + client->ws->tree->children->nodes[0]->parent = client->ws->tree; + client->ws->tree->children->nodes[1]->parent = client->ws->tree; wm_treenode_split_space(client->ws->tree, &client->ws->tree->children->nodes[0]->pos, &client->ws->tree->children->nodes[1]->pos); } else {