diff options
author | vaxerski <[email protected]> | 2023-03-02 12:04:41 +0000 |
---|---|---|
committer | vaxerski <[email protected]> | 2023-03-02 12:04:41 +0000 |
commit | dea71875e40d5ff4ad649b3c04b02419b06da5df (patch) | |
tree | 01db14a7b825f6a797d415bf6919b8b32483f4d8 | |
parent | 76fc12869d186e59cf22d51e99e2909bf1828011 (diff) | |
download | Hyprland-dea71875e40d5ff4ad649b3c04b02419b06da5df.tar.gz Hyprland-dea71875e40d5ff4ad649b3c04b02419b06da5df.zip |
add desc: to getMonitorFromString
-rw-r--r-- | src/Compositor.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 84502f18..fed97611 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -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(); } |