diff --git a/src/node.cpp b/src/node.cpp index 5b15615..ca72f03 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -320,6 +320,7 @@ bool Node::move_node(int from, int to) { void Node::insert_node(std::shared_ptr node, int index) { auto position = new_node_position(index); + node->parent = shared_from_this(); node->set_rectangle(position); sub_nodes.insert(sub_nodes.begin() + index, node); } \ No newline at end of file diff --git a/src/window_tree.cpp b/src/window_tree.cpp index 6804833..6d1abf9 100644 --- a/src/window_tree.cpp +++ b/src/window_tree.cpp @@ -179,13 +179,13 @@ bool WindowTree::try_move_active_window(miracle::WindowMoveDirection direction) // get inserted into the parent node at the index before // the currently active lane. auto node_to_move = active_lane->get_sub_nodes()[node_index]; - advise_delete_window(node_to_move->get_window()); int active_lane_index = 0; for (; active_lane_index < parent->get_sub_nodes().size(); active_lane_index++) if (parent->get_sub_nodes()[active_lane_index] == active_lane) break; + advise_delete_window(node_to_move->get_window()); parent->insert_node(node_to_move, active_lane_index); active_lane = parent; } @@ -203,13 +203,13 @@ bool WindowTree::try_move_active_window(miracle::WindowMoveDirection direction) // get inserted into the parent node at the index before // the currently active lane. auto node_to_move = active_lane->get_sub_nodes()[node_index]; - advise_delete_window(node_to_move->get_window()); int active_lane_index = 0; for (; active_lane_index < parent->get_sub_nodes().size(); active_lane_index++) if (parent->get_sub_nodes()[active_lane_index] == active_lane) break; + advise_delete_window(node_to_move->get_window()); parent->insert_node(node_to_move, active_lane_index + 1); active_lane = parent; }