mirror of
https://github.com/miracle-wm-org/miracle-wm.git
synced 2024-11-23 12:15:59 +03:00
bugfix: workspaces now get deleted when you navigate away from an empty one
This commit is contained in:
parent
f979aa3725
commit
6691e83d9e
@ -36,31 +36,50 @@ void Screen::advise_new_workspace(char workspace)
|
||||
make_workspace_active(workspace);
|
||||
}
|
||||
|
||||
void Screen::advise_workspace_deleted(char workspace)
|
||||
{
|
||||
for (auto it = workspaces.begin(); it != workspaces.end(); it++)
|
||||
{
|
||||
if (it->workspace == workspace)
|
||||
{
|
||||
workspaces.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Screen::make_workspace_active(char key)
|
||||
{
|
||||
for (auto& workspace : workspaces)
|
||||
{
|
||||
if (workspace.workspace == key)
|
||||
{
|
||||
// Deactivate current workspace
|
||||
ScreenWorkspaceInfo* previous_workspace = nullptr;
|
||||
for (auto& other : workspaces)
|
||||
{
|
||||
if (other.workspace == active_workspace)
|
||||
{
|
||||
previous_workspace = &other;
|
||||
hide(other);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Active new workspace
|
||||
active_workspace = key;
|
||||
show(workspace);
|
||||
|
||||
active_workspace = key;
|
||||
// Important: Delete the workspace only after we have shown the new one because we may want
|
||||
// to move a node to the new workspace.
|
||||
if (previous_workspace != nullptr)
|
||||
{
|
||||
auto& active_tree = previous_workspace->tree;
|
||||
if (active_tree.is_empty())
|
||||
workspace_manager.delete_workspace(previous_workspace->workspace);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
active_workspace = key;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
|
||||
WindowTree& get_active_tree();
|
||||
void advise_new_workspace(char workspace);
|
||||
void advise_workspace_deleted(char workspace);
|
||||
bool make_workspace_active(char workspace);
|
||||
std::vector<ScreenWorkspaceInfo>& get_workspaces() { return workspaces; }
|
||||
void advise_application_zone_create(miral::Zone const& application_zone);
|
||||
@ -52,7 +53,7 @@ private:
|
||||
miral::WindowManagerTools tools;
|
||||
geom::Rectangle area;
|
||||
WindowTreeOptions options;
|
||||
char active_workspace;
|
||||
char active_workspace = '\0';
|
||||
std::vector<ScreenWorkspaceInfo> workspaces;
|
||||
std::vector<miral::Zone> application_zone_list;
|
||||
|
||||
|
@ -782,7 +782,7 @@ void WindowTree::show()
|
||||
}
|
||||
|
||||
is_hidden = false;
|
||||
for (auto other_node : nodes_to_resurrect)
|
||||
for (auto& other_node : nodes_to_resurrect)
|
||||
{
|
||||
auto& window_info = tools.info_for(other_node.node->get_window());
|
||||
miral::WindowSpecification modifications;
|
||||
@ -797,4 +797,15 @@ void WindowTree::show()
|
||||
std::shared_ptr<Node> WindowTree::get_root_node()
|
||||
{
|
||||
return root_lane;
|
||||
}
|
||||
|
||||
bool WindowTree::is_empty()
|
||||
{
|
||||
bool empty = true;
|
||||
foreach_node([&](auto node)
|
||||
{
|
||||
if (node->is_window())
|
||||
empty = false;
|
||||
});
|
||||
return empty;
|
||||
}
|
@ -106,6 +106,7 @@ public:
|
||||
|
||||
std::shared_ptr<Node> get_root_node();
|
||||
void _recalculate_root_node_area();
|
||||
bool is_empty();
|
||||
|
||||
private:
|
||||
struct MoveResult
|
||||
@ -135,6 +136,7 @@ private:
|
||||
bool is_hidden = false;
|
||||
std::vector<NodeResurrection> nodes_to_resurrect;
|
||||
|
||||
// TODO: Move non tiling window list to Screen
|
||||
std::vector<miral::Window> non_tiling_window_list;
|
||||
std::shared_ptr<Node> _get_active_lane();
|
||||
void _handle_direction_request(NodeLayoutDirection direction);
|
||||
|
@ -79,4 +79,19 @@ bool WorkspaceManager::move_active_to_workspace(std::shared_ptr<Screen> screen,
|
||||
screen_to_move_to->get_active_tree().advise_new_window(prev_info);
|
||||
screen_to_move_to->get_active_tree().handle_window_ready(prev_info);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WorkspaceManager::delete_workspace(char key)
|
||||
{
|
||||
for (auto it = workspaces.begin(); it != workspaces.end(); it++)
|
||||
{
|
||||
if (it->key == key)
|
||||
{
|
||||
it->screen->advise_workspace_deleted(key);
|
||||
workspaces.erase(it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
@ -49,6 +49,8 @@ public:
|
||||
|
||||
bool move_active_to_workspace(std::shared_ptr<Screen> screen, char workspace);
|
||||
|
||||
bool delete_workspace(char workspace);
|
||||
|
||||
private:
|
||||
WindowManagerTools tools_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user