config: Fix matching monitor by description to allow space prefix (#9788)

This commit is contained in:
Emad Elsaid 2025-03-30 03:12:15 +02:00 committed by GitHub
parent 05eb0aa43d
commit da2d7c3971
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -1707,8 +1707,8 @@ void CConfigManager::addParseError(const std::string& err) {
PHLMONITOR CConfigManager::getBoundMonitorForWS(const std::string& wsname) { PHLMONITOR CConfigManager::getBoundMonitorForWS(const std::string& wsname) {
auto monitor = getBoundMonitorStringForWS(wsname); auto monitor = getBoundMonitorStringForWS(wsname);
if (monitor.substr(0, 5) == "desc:") if (monitor.starts_with("desc:"))
return g_pCompositor->getMonitorFromDesc(monitor.substr(5)); return g_pCompositor->getMonitorFromDesc(trim(monitor.substr(5)));
else else
return g_pCompositor->getMonitorFromName(monitor); return g_pCompositor->getMonitorFromName(monitor);
} }
@ -1798,8 +1798,8 @@ std::string CConfigManager::getDefaultWorkspaceFor(const std::string& name) {
if (other->isDefault) { if (other->isDefault) {
if (other->monitor == name) if (other->monitor == name)
return other->workspaceString; return other->workspaceString;
if (other->monitor.substr(0, 5) == "desc:") { if (other->monitor.starts_with("desc:")) {
auto const monitor = g_pCompositor->getMonitorFromDesc(other->monitor.substr(5)); auto const monitor = g_pCompositor->getMonitorFromDesc(trim(other->monitor.substr(5)));
if (monitor && monitor->szName == name) if (monitor && monitor->szName == name)
return other->workspaceString; return other->workspaceString;
} }

View file

@ -881,7 +881,7 @@ bool CMonitor::isMirror() {
bool CMonitor::matchesStaticSelector(const std::string& selector) const { bool CMonitor::matchesStaticSelector(const std::string& selector) const {
if (selector.starts_with("desc:")) { if (selector.starts_with("desc:")) {
// match by description // match by description
const auto DESCRIPTIONSELECTOR = selector.substr(5); const auto DESCRIPTIONSELECTOR = trim(selector.substr(5));
return szDescription.starts_with(DESCRIPTIONSELECTOR) || szShortDescription.starts_with(DESCRIPTIONSELECTOR); return szDescription.starts_with(DESCRIPTIONSELECTOR) || szShortDescription.starts_with(DESCRIPTIONSELECTOR);
} else { } else {