diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-05-05 15:33:31 +0100 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-05-05 15:33:31 +0100 |
| commit | a5d63a0324649fd056da1d1e09b435333defb4f3 (patch) | |
| tree | bb8dfbe5efc1624e4d092a77a37aae33e03fd3fb /src/config/ConfigManager.cpp | |
| parent | 8435d6fc124b25aa07b8129d1baf4c6483c54ea7 (diff) | |
configmanager: store workspace rules as a deque
Diffstat (limited to 'src/config/ConfigManager.cpp')
| -rw-r--r-- | src/config/ConfigManager.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 0941231c..b401f1dc 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -583,7 +583,7 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string wsRule.workspaceName = name; wsRule.workspaceId = wsId; - m_mWorkspaceRules[wsId] = wsRule; + m_dWorkspaceRules.emplace_back(wsRule); argno++; } else { Debug::log(ERR, "Config error: invalid monitor syntax"); @@ -1033,6 +1033,7 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std: } wsRule.monitor = first_ident; wsRule.workspaceString = wsIdent; + wsRule.isDefault = true; // backwards compat rules = value.substr(WORKSPACE_DELIM + 1); } @@ -1053,6 +1054,8 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std: wsRule.decorate = configStringToInt(rule.substr(delim + 9)); else if ((delim = rule.find("monitor:")) != std::string::npos) wsRule.monitor = rule.substr(delim + 8); + else if ((delim = rule.find("default:")) != std::string::npos) + wsRule.isDefault = configStringToInt(rule.substr(delim + 9)); }; size_t pos = 0; @@ -1064,9 +1067,10 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std: } assignRule(rules); // match remaining rule - wsRule.workspaceId = id; - wsRule.workspaceName = name; - m_mWorkspaceRules[id] = wsRule; + wsRule.workspaceId = id; + wsRule.workspaceName = name; + + m_dWorkspaceRules.emplace_back(wsRule); } void CConfigManager::handleSubmap(const std::string& command, const std::string& submap) { @@ -1377,7 +1381,7 @@ void CConfigManager::loadConfigLoadVars() { deviceConfigs.clear(); m_dBlurLSNamespaces.clear(); boundWorkspaces.clear(); - m_mWorkspaceRules.clear(); + m_dWorkspaceRules.clear(); setDefaultAnimationVars(); // reset anims m_vDeclaredPlugins.clear(); m_dLayerRules.clear(); @@ -1681,14 +1685,10 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const std::string& name, const st } SWorkspaceRule CConfigManager::getWorkspaceRuleFor(CWorkspace* pWorkspace) { - if (m_mWorkspaceRules.contains(pWorkspace->m_iID)) { - return m_mWorkspaceRules.at(pWorkspace->m_iID); - } - - const auto IT = std::find_if(m_mWorkspaceRules.begin(), m_mWorkspaceRules.end(), [&](const auto& other) { return other.second.workspaceName == pWorkspace->m_szName; }); - if (IT == m_mWorkspaceRules.end()) + const auto IT = std::find_if(m_dWorkspaceRules.begin(), m_dWorkspaceRules.end(), [&](const auto& other) { return other.workspaceName == pWorkspace->m_szName; }); + if (IT == m_dWorkspaceRules.end()) return SWorkspaceRule{}; - return IT->second; + return *IT; } std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) { @@ -2098,8 +2098,8 @@ void CConfigManager::removePluginConfig(HANDLE handle) { } std::string CConfigManager::getDefaultWorkspaceFor(const std::string& name) { - const auto IT = std::find_if(m_mWorkspaceRules.begin(), m_mWorkspaceRules.end(), [&](const auto& other) { return other.second.monitor == name; }); - if (IT == m_mWorkspaceRules.end()) + const auto IT = std::find_if(m_dWorkspaceRules.begin(), m_dWorkspaceRules.end(), [&](const auto& other) { return other.monitor == name && other.isDefault; }); + if (IT == m_dWorkspaceRules.end()) return ""; - return IT->second.workspaceString; + return IT->workspaceString; } |
