diff options
| author | ItsOhen <TNordfeldt@gmail.com> | 2025-09-29 20:10:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-29 20:10:34 +0200 |
| commit | 38c1e72c9d81fcdad8f173e06102a5da18836230 (patch) | |
| tree | aad2d03d0ab45280e313b75451a0d125be86ddaf /src | |
| parent | 09596725910aab2a9defed250348aebeee40f842 (diff) | |
rules: fix some monitor rules (#11873)
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/ConfigManager.cpp | 13 | ||||
| -rw-r--r-- | src/events/Windows.cpp | 26 |
2 files changed, 17 insertions, 22 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 206de193..1ff2d293 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -2669,16 +2669,17 @@ std::optional<std::string> CConfigManager::handleWindowRule(const std::string& c bool parsingParams = false; for (const auto& varStr : VARLIST) { - std::string_view var = varStr; - auto sep = var.find(':'); - std::string_view key = (sep != std::string_view::npos) ? var.substr(0, sep) : var; + std::string_view var = varStr; + auto sep = var.find(':'); + std::string_view key = (sep != std::string_view::npos) ? var.substr(0, sep) : var; + bool isParam = (sep != std::string_view::npos && !(key.starts_with("workspace ") || (key.starts_with("monitor ")) || key.ends_with("plugin"))); if (!parsingParams) { - // Don't be alarmed, ends_with is a single memcmp, i went and checked. - if (sep == std::string_view::npos || key.ends_with("plugin") || key.ends_with("special")) { + if (!isParam) { tokens.emplace_back(var); continue; } + parsingParams = true; } @@ -2964,7 +2965,7 @@ std::optional<std::string> CConfigManager::handleWorkspaceRules(const std::strin CHECK_OR_THROW(configStringToInt(rule.substr(delim + 11))) wsRule.isPersistent = *X; } else if ((delim = rule.find("defaultName:")) != std::string::npos) - wsRule.defaultName = rule.substr(delim + 12); + wsRule.defaultName = trim(rule.substr(delim + 12)); else if ((delim = rule.find(ruleOnCreatedEmpty)) != std::string::npos) { CHECK_OR_THROW(cleanCmdForWorkspace(name, rule.substr(delim + ruleOnCreatedEmptyLen))) wsRule.onCreatedEmptyRunCmd = *X; diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 8f40c0e1..16f71534 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -15,6 +15,7 @@ #include "../protocols/ToplevelExport.hpp" #include "../protocols/types/ContentType.hpp" #include "../xwayland/XSurface.hpp" +#include "desktop/DesktopTypes.hpp" #include "managers/animation/AnimationManager.hpp" #include "managers/animation/DesktopAnimationManager.hpp" #include "managers/PointerManager.hpp" @@ -147,23 +148,16 @@ void Events::listener_mapWindow(void* owner, void* data) { try { const auto MONITORSTR = trim(r->m_rule.substr(r->m_rule.find(' '))); - if (MONITORSTR == "unset") { + if (MONITORSTR == "unset") PWINDOW->m_monitor = PMONITOR; - } else { - if (isNumber(MONITORSTR)) { - const MONITORID MONITOR = std::stoi(MONITORSTR); - if (const auto PM = g_pCompositor->getMonitorFromID(MONITOR); PM) - PWINDOW->m_monitor = PM; - else - PWINDOW->m_monitor = g_pCompositor->m_monitors.at(0); - } else { - const auto PMONITOR = g_pCompositor->getMonitorFromName(MONITORSTR); - if (PMONITOR) - PWINDOW->m_monitor = PMONITOR; - else { - Debug::log(ERR, "No monitor in monitor {} rule", MONITORSTR); - continue; - } + else { + const auto MONITOR = g_pCompositor->getMonitorFromString(MONITORSTR); + + if (MONITOR) + PWINDOW->m_monitor = MONITOR; + else { + Debug::log(ERR, "No monitor in monitor {} rule", MONITORSTR); + continue; } } |
