monitor desc default workspace but working now (#2678)

* fix desc check

* fixes crashes when nulptr
This commit is contained in:
MightyPlaza 2023-07-11 09:29:19 +00:00 committed by GitHub
parent 26579fa962
commit 29d017f54b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View file

@ -495,17 +495,14 @@ CMonitor* CCompositor::getMonitorFromName(const std::string& name) {
return m.get(); return m.get();
} }
} }
return nullptr; return nullptr;
} }
CMonitor* CCompositor::getMonitorFromDesc(const std::string& desc) { CMonitor* CCompositor::getMonitorFromDesc(const std::string& desc) {
for (auto& m : m_vMonitors) { for (auto& m : m_vMonitors) {
if (desc == m->output->description) { if (m->output->description && std::string(m->output->description).find(desc) == 0)
return m.get(); return m.get();
}
} }
return nullptr; return nullptr;
} }

View file

@ -2195,8 +2195,15 @@ void CConfigManager::removePluginConfig(HANDLE handle) {
std::string CConfigManager::getDefaultWorkspaceFor(const std::string& name) { std::string CConfigManager::getDefaultWorkspaceFor(const std::string& name) {
for (auto other = m_dWorkspaceRules.begin(); other != m_dWorkspaceRules.end(); ++other) { for (auto other = m_dWorkspaceRules.begin(); other != m_dWorkspaceRules.end(); ++other) {
if (other->isDefault && (other->monitor == name || (other->monitor.substr(0, 5) == "desc:" && g_pCompositor->getMonitorFromDesc(other->monitor.substr(5))->szName == name))) if (other->isDefault) {
return other->workspaceString; if (other->monitor == name)
return other->workspaceString;
if (other->monitor.substr(0, 5) == "desc:") {
auto monitor = g_pCompositor->getMonitorFromDesc(other->monitor.substr(5));
if (monitor && monitor->szName == name)
return other->workspaceString;
}
}
} }
return ""; return "";
} }