mirror of
https://github.com/miracle-wm-org/miracle-wm.git
synced 2024-11-23 12:15:59 +03:00
feature: when a WindowTree is removed, then we add its contents to any other tree that we can find
This commit is contained in:
parent
96eefa2ea9
commit
057ecddd5c
@ -273,7 +273,10 @@ void MiracleWindowManagementPolicy::advise_output_delete(miral::Output const& ou
|
||||
if (tree_list.empty())
|
||||
active_tree = nullptr;
|
||||
else
|
||||
{
|
||||
active_tree = tree_list[0];
|
||||
active_tree->tree.add_tree(it->tree);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
bool is_window() const { return state == NodeState::window; }
|
||||
bool is_lane() const { return state == NodeState::lane; }
|
||||
NodeLayoutDirection get_direction() const { return direction; }
|
||||
miral::Window const& get_window() const { return window; }
|
||||
miral::Window& get_window() { return window; }
|
||||
std::shared_ptr<Node> get_parent() const { return parent; }
|
||||
std::vector<std::shared_ptr<Node>> const& get_sub_nodes() const { return sub_nodes; }
|
||||
|
||||
|
@ -619,4 +619,35 @@ bool WindowTree::constrain(miral::WindowInfo &window_info)
|
||||
|
||||
node->get_parent()->constrain();
|
||||
return true;
|
||||
}
|
||||
|
||||
void WindowTree::add_tree(WindowTree& other_tree)
|
||||
{
|
||||
other_tree.foreach_node([&](auto node)
|
||||
{
|
||||
if (node->is_window())
|
||||
{
|
||||
auto new_node_position = root_lane->create_new_node_position();
|
||||
node->set_logical_area(new_node_position);
|
||||
root_lane->add_window(node->get_window());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void foreach_node_internal(std::function<void(std::shared_ptr<Node>)> f, std::shared_ptr<Node> parent)
|
||||
{
|
||||
f(parent);
|
||||
if (parent->is_window())
|
||||
return;
|
||||
|
||||
for (auto node : parent->get_sub_nodes())
|
||||
foreach_node_internal(f, node);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowTree::foreach_node(std::function<void(std::shared_ptr<Node>)> f)
|
||||
{
|
||||
foreach_node_internal(f, root_lane);
|
||||
}
|
@ -94,6 +94,10 @@ public:
|
||||
/// Constrains the window to its tile if it is in this tree.
|
||||
bool constrain(miral::WindowInfo& window_info);
|
||||
|
||||
void add_tree(WindowTree&);
|
||||
|
||||
void foreach_node(std::function<void(std::shared_ptr<Node>)>);
|
||||
|
||||
private:
|
||||
miral::WindowManagerTools tools;
|
||||
WindowTreeOptions options;
|
||||
|
Loading…
Reference in New Issue
Block a user