mirror of
https://github.com/miracle-wm-org/miracle-wm.git
synced 2024-12-02 08:48:07 +03:00
bugfix: leaving the algorithm for now, but we nee a quick cleanup sesh
This commit is contained in:
parent
9f585b3042
commit
7cdb097087
24
src/node.cpp
24
src/node.cpp
@ -348,24 +348,14 @@ std::shared_ptr<Node> Node::node_at(int i)
|
||||
return sub_nodes[i];
|
||||
}
|
||||
|
||||
std::shared_ptr<Node> Node::find_first_window_child()
|
||||
std::shared_ptr<Node> Node::find_nth_window_child(int i)
|
||||
{
|
||||
if (is_window())
|
||||
return shared_from_this();
|
||||
|
||||
for (auto node : sub_nodes)
|
||||
{
|
||||
if (node->is_window())
|
||||
return node;
|
||||
}
|
||||
if (i < 0 || i >= sub_nodes.size())
|
||||
return nullptr;
|
||||
|
||||
for (auto node : sub_nodes)
|
||||
{
|
||||
auto first_child = node->find_first_window_child();
|
||||
if (first_child)
|
||||
return nullptr;
|
||||
}
|
||||
if (sub_nodes[i]->is_window())
|
||||
return sub_nodes[i];
|
||||
|
||||
std::cerr << "Cannot discover a first child for this lane\n";
|
||||
return nullptr;
|
||||
// The lane is correct, so let's get the first window in that lane.
|
||||
return sub_nodes[i]->find_nth_window_child(0);
|
||||
}
|
@ -87,7 +87,7 @@ public:
|
||||
std::shared_ptr<Node> node_at(int i);
|
||||
|
||||
void to_lane();
|
||||
std::shared_ptr<Node> find_first_window_child();
|
||||
std::shared_ptr<Node> find_nth_window_child(int i);
|
||||
|
||||
private:
|
||||
miral::Window window;
|
||||
|
@ -181,9 +181,11 @@ bool WindowTree::try_move_active_window(miracle::Direction direction)
|
||||
if (!parent)
|
||||
return false;
|
||||
|
||||
auto index_of_second = parent->get_index_of_node(second_window);
|
||||
auto insertion_index = parent->get_index_of_node(second_window);
|
||||
advise_delete_window(active_window);
|
||||
parent->insert_node(first_window, index_of_second);
|
||||
parent->insert_node(first_window, insertion_index);
|
||||
active_lane = parent;
|
||||
active_window = first_window->get_window();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -326,20 +328,14 @@ std::shared_ptr<Node> WindowTree::traverse(std::shared_ptr<Node> from, Direction
|
||||
if (is_negative)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
// TODO: lazy lazy for readability
|
||||
goto grandparent_route;
|
||||
}
|
||||
goto grandparent_route; // TODO: lazy lazy for readability
|
||||
else
|
||||
return parent->node_at(index - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (index == parent->num_nodes() - 1)
|
||||
{
|
||||
// TODO: lazy lazy for readability
|
||||
goto grandparent_route;
|
||||
}
|
||||
goto grandparent_route; // TODO: lazy lazy for readability
|
||||
else
|
||||
return parent->node_at(index + 1);
|
||||
}
|
||||
@ -358,12 +354,19 @@ grandparent_route:
|
||||
}
|
||||
|
||||
do {
|
||||
auto index_of_parent = grandparent->get_index_of_node(parent);
|
||||
if (is_negative)
|
||||
index_of_parent--;
|
||||
else
|
||||
index_of_parent++;
|
||||
|
||||
if (grandparent->get_direction() == NodeLayoutDirection::horizontal && !is_vertical
|
||||
|| grandparent->get_direction() == NodeLayoutDirection::vertical && is_vertical)
|
||||
{
|
||||
return grandparent->find_first_window_child();
|
||||
return grandparent->find_nth_window_child(index_of_parent);
|
||||
}
|
||||
|
||||
parent = grandparent;
|
||||
grandparent = grandparent->parent;
|
||||
} while (grandparent != nullptr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user