feat: create persistent workspaces after regular ones at init
feat: avoid recreating duplicate workspacespull/2578/head
parent
a41225c4e0
commit
7d5577a2ed
|
@ -458,11 +458,11 @@ std::optional<std::string> Workspace::on_window_closed(WindowAddress &addr) {
|
||||||
|
|
||||||
void Workspaces::create_workspace(Json::Value &workspace_data, const Json::Value &clients_data) {
|
void Workspaces::create_workspace(Json::Value &workspace_data, const Json::Value &clients_data) {
|
||||||
// avoid recreating existing workspaces
|
// avoid recreating existing workspaces
|
||||||
|
auto workspace_name = workspace_data["name"].asString();
|
||||||
auto workspace = std::find_if(
|
auto workspace = std::find_if(
|
||||||
workspaces_.begin(), workspaces_.end(), [&](std::unique_ptr<Workspace> const &x) {
|
workspaces_.begin(), workspaces_.end(), [&](std::unique_ptr<Workspace> const &w) {
|
||||||
auto name = workspace_data["name"].asString();
|
return (workspace_name.starts_with("special:") && workspace_name.substr(8) == w->name()) ||
|
||||||
return x->is_persistent() &&
|
workspace_name == w->name();
|
||||||
((name.starts_with("special:") && name.substr(8) == x->name()) || name == x->name());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (workspace != workspaces_.end()) {
|
if (workspace != workspaces_.end()) {
|
||||||
|
@ -589,9 +589,6 @@ void Workspaces::init() {
|
||||||
monitor_id_ = (*current_monitor)["id"].asInt();
|
monitor_id_ = (*current_monitor)["id"].asInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
fill_persistent_workspaces();
|
|
||||||
create_persistent_workspaces();
|
|
||||||
|
|
||||||
const Json::Value workspaces_json = gIPC->getSocket1JsonReply("workspaces");
|
const Json::Value workspaces_json = gIPC->getSocket1JsonReply("workspaces");
|
||||||
const Json::Value clients_json = gIPC->getSocket1JsonReply("clients");
|
const Json::Value clients_json = gIPC->getSocket1JsonReply("clients");
|
||||||
|
|
||||||
|
@ -604,6 +601,9 @@ void Workspaces::init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fill_persistent_workspaces();
|
||||||
|
create_persistent_workspaces();
|
||||||
|
|
||||||
update_window_count();
|
update_window_count();
|
||||||
|
|
||||||
sort_workspaces();
|
sort_workspaces();
|
||||||
|
|
Loading…
Reference in New Issue