Skip to content

Commit 06602d6

Browse files
committed
fix: Revert workspace creation logic
1 parent fa3ab26 commit 06602d6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/modules/hyprland/workspaces.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,18 @@ Json::Value Workspaces::createMonitorWorkspaceData(std::string const &name,
6464

6565
void Workspaces::createWorkspace(Json::Value const &workspace_data,
6666
Json::Value const &clients_data) {
67+
auto workspaceName = workspace_data["name"].asString();
6768
auto workspaceId = workspace_data["id"].asInt();
68-
spdlog::debug("Creating workspace {}", workspaceId);
69+
spdlog::debug("Creating workspace {}", workspaceName);
6970

7071
// avoid recreating existing workspaces
7172
auto workspace =
72-
std::ranges::find_if(m_workspaces, [workspaceId](std::unique_ptr<Workspace> const &w) {
73-
return workspaceId == w->id();
73+
std::ranges::find_if(m_workspaces, [&](std::unique_ptr<Workspace> const &w) {
74+
if (workspaceId > 0) {
75+
return w->id() == workspaceId;
76+
}
77+
return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) ||
78+
workspaceName == w->name();
7479
});
7580

7681
if (workspace != m_workspaces.end()) {
@@ -79,14 +84,14 @@ void Workspaces::createWorkspace(Json::Value const &workspace_data,
7984

8085
const auto *k = "persistent-rule";
8186
if (std::ranges::find(keys, k) != keys.end()) {
82-
spdlog::debug("Set dynamic persistency of workspace {} to: {}", workspaceId,
87+
spdlog::debug("Set dynamic persistency of workspace {} to: {}", workspaceName,
8388
workspace_data[k].asBool() ? "true" : "false");
8489
(*workspace)->setPersistentRule(workspace_data[k].asBool());
8590
}
8691

8792
k = "persistent-config";
8893
if (std::ranges::find(keys, k) != keys.end()) {
89-
spdlog::debug("Set config persistency of workspace {} to: {}", workspaceId,
94+
spdlog::debug("Set config persistency of workspace {} to: {}", workspaceName,
9095
workspace_data[k].asBool() ? "true" : "false");
9196
(*workspace)->setPersistentConfig(workspace_data[k].asBool());
9297
}

0 commit comments

Comments
 (0)