From d9f7f039e13b7d40c1d3e65809b65a96f0c68781 Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Sun, 9 Jul 2023 21:10:35 +0000 Subject: [PATCH] monitor desc support (#2670) * monitor desc * monitor desc --- src/Compositor.cpp | 10 ++++++++++ src/Compositor.hpp | 4 ++-- src/config/ConfigManager.cpp | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 50ea0b5d..89c0d08b 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -499,6 +499,16 @@ CMonitor* CCompositor::getMonitorFromName(const std::string& name) { return nullptr; } +CMonitor* CCompositor::getMonitorFromDesc(const std::string& desc) { + for (auto& m : m_vMonitors) { + if (desc == m->output->description) { + return m.get(); + } + } + + return nullptr; +} + CMonitor* CCompositor::getMonitorFromCursor() { const auto COORDS = Vector2D(m_sWLRCursor->x, m_sWLRCursor->y); diff --git a/src/Compositor.hpp b/src/Compositor.hpp index e4f5483f..55633fc6 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -28,8 +28,7 @@ #include "hyprerror/HyprError.hpp" #include "plugins/PluginSystem.hpp" -enum eManagersInitStage -{ +enum eManagersInitStage { STAGE_PRIORITY = 0, STAGE_LATE }; @@ -125,6 +124,7 @@ class CCompositor { CMonitor* getMonitorFromID(const int&); CMonitor* getMonitorFromName(const std::string&); + CMonitor* getMonitorFromDesc(const std::string&); CMonitor* getMonitorFromCursor(); CMonitor* getMonitorFromVector(const Vector2D&); void removeWindowFromVectorSafe(CWindow*); diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 2cf6a5c4..e6894865 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -2106,7 +2106,11 @@ void CConfigManager::addParseError(const std::string& err) { } CMonitor* CConfigManager::getBoundMonitorForWS(const std::string& wsname) { - return g_pCompositor->getMonitorFromName(getBoundMonitorStringForWS(wsname)); + auto monitor = getBoundMonitorStringForWS(wsname); + if (monitor.substr(0, 5) == "desc:") + return g_pCompositor->getMonitorFromDesc(monitor.substr(5)); + else + return g_pCompositor->getMonitorFromName(monitor); } std::string CConfigManager::getBoundMonitorStringForWS(const std::string& wsname) {