small fixes

This commit is contained in:
arnaud-ma
2025-07-19 05:01:29 +02:00
parent 2dc2b5ccfd
commit 8dcdd97879
2 changed files with 11 additions and 7 deletions

View File

@ -119,6 +119,7 @@ class Workspaces : public AModule, public EventHandler {
void setCurrentMonitorId(); void setCurrentMonitorId();
void loadPersistentWorkspacesFromConfig(Json::Value const& clientsJson); void loadPersistentWorkspacesFromConfig(Json::Value const& clientsJson);
void loadPersistentWorkspacesFromWorkspaceRules(const Json::Value& clientsJson); void loadPersistentWorkspacesFromWorkspaceRules(const Json::Value& clientsJson);
bool m_allOutputs = false; bool m_allOutputs = false;
bool m_showSpecial = false; bool m_showSpecial = false;
bool m_activeOnly = false; bool m_activeOnly = false;

View File

@ -69,13 +69,14 @@ void Workspaces::createWorkspace(Json::Value const &workspace_data,
spdlog::debug("Creating workspace {}", workspaceName); spdlog::debug("Creating workspace {}", workspaceName);
// avoid recreating existing workspaces // avoid recreating existing workspaces
auto workspace = std::ranges::find_if(m_workspaces, [&](std::unique_ptr<Workspace> const &w) { auto workspace =
if (workspaceId > 0) { std::ranges::find_if(m_workspaces, [&](std::unique_ptr<Workspace> const &w) {
return w->id() == workspaceId; if (workspaceId > 0) {
} return w->id() == workspaceId;
return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || }
workspaceName == w->name(); return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) ||
}); workspaceName == w->name();
});
if (workspace != m_workspaces.end()) { if (workspace != m_workspaces.end()) {
// don't recreate workspace, but update persistency if necessary // don't recreate workspace, but update persistency if necessary
@ -295,6 +296,8 @@ void Workspaces::loadPersistentWorkspacesFromWorkspaceRules(const Json::Value &c
} }
auto workspace = rule.isMember("defaultName") ? rule["defaultName"].asString() auto workspace = rule.isMember("defaultName") ? rule["defaultName"].asString()
: rule["workspaceString"].asString(); : rule["workspaceString"].asString();
// The prefix "name:" cause mismatches with workspace names taken anywhere else.
if (workspace.starts_with("name:")) { if (workspace.starts_with("name:")) {
workspace = workspace.substr(5); workspace = workspace.substr(5);
} }