add desc: to getMonitorFromString

This commit is contained in:
Vaxry 2023-03-02 12:04:41 +00:00
parent 76fc12869d
commit dea71875e4

View file

@ -1809,21 +1809,31 @@ CMonitor* CCompositor::getMonitorFromString(const std::string& name) {
return nullptr;
}
if (monID > -1 && monID < (int)g_pCompositor->m_vMonitors.size()) {
return g_pCompositor->getMonitorFromID(monID);
if (monID > -1 && monID < (int)m_vMonitors.size()) {
return getMonitorFromID(monID);
} else {
Debug::log(ERR, "Error in getMonitorFromString: invalid arg 1");
return nullptr;
}
} else if (name.find("desc:") == 0) {
const auto DESCRIPTION = name.substr(5);
for (auto& m : m_vMonitors) {
if (m->output->description && std::string(m->output->description).find(DESCRIPTION) == 0) {
return m.get();
}
}
return nullptr;
} else {
if (name == "current")
return g_pCompositor->m_pLastMonitor;
if (isDirection(name)) {
const auto PMONITOR = g_pCompositor->getMonitorInDirection(name[0]);
const auto PMONITOR = getMonitorInDirection(name[0]);
return PMONITOR;
} else {
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto& m : m_vMonitors) {
if (m->szName == name) {
return m.get();
}