diff --git a/hyprtester/src/tests/main/window.cpp b/hyprtester/src/tests/main/window.cpp index 9880997e..143c1245 100644 --- a/hyprtester/src/tests/main/window.cpp +++ b/hyprtester/src/tests/main/window.cpp @@ -237,7 +237,6 @@ static bool test() { EXPECT_CONTAINS(str, "floating: 1"); EXPECT_CONTAINS(str, std::format("size: {},{}", SIZE, SIZE)); EXPECT_NOT_CONTAINS(str, "pinned: 1"); - OK(getFromSocket("/keyword windowrule plugin:someplugin:variable, class:wr_kitty")); OK(getFromSocket("/keyword windowrule plugin:someplugin:variable 10, class:wr_kitty")); OK(getFromSocket("/keyword windowrule workspace 1, class:wr_kitty")); @@ -246,6 +245,7 @@ static bool test() { if (!spawnKitty("magic_kitty")) return false; EXPECT_CONTAINS(getFromSocket("/activewindow"), "special:magic"); + EXPECT_NOT_CONTAINS(str, "workspace: 9"); } NLog::log("{}Testing faulty rules", Colors::YELLOW); { 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 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 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; } }