Skip to content

Commit

Permalink
bugfix: able to append and prepend movements to the root node
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkae committed Feb 17, 2024
1 parent 4847769 commit ff5d9d4
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/window_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,18 +268,6 @@ bool WindowTree::try_move_active_window(miracle::Direction direction)
goto do_insert;
}

if (second_parent->num_nodes() == 1)
{
if (second_parent->get_parent() == first_parent)
{
auto grandparent = second_parent->get_parent();
grandparent->swap_nodes(active_window, second_parent);
break;
}

goto do_insert;
}

do_insert:
auto index = second_parent->get_index_of_node(second_window);
auto moving_node = active_window;
Expand Down Expand Up @@ -485,9 +473,8 @@ WindowTree::MoveResult WindowTree::_move(std::shared_ptr<Node>const& from, Direc
// Algorithm:
// 1. Perform the _select algorithm. If that passes, then we want to be where the selected node
// currently is
// 2. If NO node matches, then we still have to move. This means that we must create a new root node with the
// requested direction ONLY IF the directions don't agree. If the directions agree, then we just have nowhere
// to go.
// 2. If our parent layout direction does not equal the root layout direction, we can append
// or prepend to the root
if (auto insert_node = _select(from, direction))
{
return {
Expand All @@ -496,6 +483,22 @@ WindowTree::MoveResult WindowTree::_move(std::shared_ptr<Node>const& from, Direc
};
}

auto parent = from->get_parent();
if (root_lane->get_direction() != parent->get_direction())
{
bool is_negative = direction == Direction::left || direction == Direction::up;
if (is_negative)
return {
MoveResult::traversal_type_prepend,
root_lane
};
else
return {
MoveResult::traversal_type_append,
root_lane
};
}

return {};
}

Expand Down

0 comments on commit ff5d9d4

Please sign in to comment.