From 71e2562a4151b506cece69f7d121847957d4bac4 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Wed, 5 Oct 2022 10:22:33 +0100 Subject: [PATCH] add desc: to monitor rules --- src/config/ConfigManager.cpp | 8 ++++---- src/config/ConfigManager.hpp | 2 +- src/debug/HyprCtl.cpp | 6 ++++-- src/helpers/Monitor.cpp | 4 ++-- src/managers/KeybindManager.cpp | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index a085f2a6..88569c5a 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1296,7 +1296,7 @@ void CConfigManager::setString(std::string v, std::string val) { configValues[v].strValue = val; } -SMonitorRule CConfigManager::getMonitorRuleFor(std::string name) { +SMonitorRule CConfigManager::getMonitorRuleFor(std::string name, std::string displayName) { SMonitorRule* found = nullptr; for (auto& r : m_dMonitorRules) { @@ -1312,7 +1312,7 @@ SMonitorRule CConfigManager::getMonitorRuleFor(std::string name) { Debug::log(WARN, "No rule found for %s, trying to use the first.", name.c_str()); for (auto& r : m_dMonitorRules) { - if (r.name == "") { + if (r.name == "" || (r.name.find("desc:") == 0 && r.name.substr(5) == displayName)) { found = &r; break; } @@ -1424,7 +1424,7 @@ void CConfigManager::performMonitorReload() { bool overAgain = false; for (auto& m : g_pCompositor->m_vRealMonitors) { - auto rule = getMonitorRuleFor(m->szName); + auto rule = getMonitorRuleFor(m->szName, m->output->description ? m->output->description : ""); // ensure mirror m->setMirror(rule.mirrorOf); @@ -1477,7 +1477,7 @@ bool CConfigManager::shouldBlurLS(const std::string& ns) { void CConfigManager::ensureDPMS() { for (auto& rm : g_pCompositor->m_vRealMonitors) { - auto rule = getMonitorRuleFor(rm->szName); + auto rule = getMonitorRuleFor(rm->szName, rm->output->description ? rm->output->description : ""); if (rule.disabled == rm->m_bEnabled) { rm->m_pThisWrap = &rm; diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 8340ef06..dfd0da9d 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -135,7 +135,7 @@ public: SConfigValue* getConfigValuePtr(std::string); SConfigValue* getConfigValuePtrSafe(std::string); - SMonitorRule getMonitorRuleFor(std::string); + SMonitorRule getMonitorRuleFor(std::string, std::string displayName = ""); CMonitor* getBoundMonitorForWS(std::string); diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 3d4b2879..5dc20f22 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -23,6 +23,7 @@ std::string monitorsRequest(HyprCtl::eHyprCtlOutputFormat format) { R"#({ "id": %i, "name": "%s", + "description": "%s", "width": %i, "height": %i, "refreshRate": %f, @@ -39,6 +40,7 @@ R"#({ },)#", m->ID, escapeJSONStrings(m->szName).c_str(), + escapeJSONStrings(m->output->description ? m->output->description : ""), (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, @@ -56,8 +58,8 @@ R"#({ result += "]"; } else { for (auto& m : g_pCompositor->m_vMonitors) { - result += getFormat("Monitor %s (ID %i):\n\t%ix%i@%f at %ix%i\n\tactive workspace: %i (%s)\n\treserved: %i %i %i %i\n\tscale: %.2f\n\ttransform: %i\n\tfocused: %s\n\n", - m->szName.c_str(), m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, m->activeWorkspace, g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName.c_str(), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "yes" : "no")); + result += getFormat("Monitor %s (ID %i):\n\t%ix%i@%f at %ix%i\n\tdescription: %s\n\tactive workspace: %i (%s)\n\treserved: %i %i %i %i\n\tscale: %.2f\n\ttransform: %i\n\tfocused: %s\n\n", + m->szName.c_str(), m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, (m->output->description ? m->output->description : ""), m->activeWorkspace, g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName.c_str(), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "yes" : "no")); } } diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index b7c6c24d..87b5edf8 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -9,7 +9,7 @@ void CMonitor::onConnect(bool noRule) { szName = output->name; // get monitor rule that matches - SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(output->name); + SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(output->name, output->description ? output->description : ""); hyprListener_monitorFrame.initCallback(&output->events.frame, &Events::listener_monitorFrame, this); hyprListener_monitorDestroy.initCallback(&output->events.destroy, &Events::listener_monitorDestroy, this); @@ -297,7 +297,7 @@ void CMonitor::setMirror(const std::string& mirrorOf) { pMirrorOf = nullptr; // set rule - const auto RULE = g_pConfigManager->getMonitorRuleFor(this->szName); + const auto RULE = g_pConfigManager->getMonitorRuleFor(this->szName, this->output->description ? this->output->description : ""); vecPosition = RULE.offset; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 337ce059..5a2d10a3 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1332,7 +1332,7 @@ void CKeybindManager::forceRendererReload(std::string args) { bool overAgain = false; for (auto& m : g_pCompositor->m_vMonitors) { - auto rule = g_pConfigManager->getMonitorRuleFor(m->szName); + auto rule = g_pConfigManager->getMonitorRuleFor(m->szName, m->output->description ? m->output->description : ""); if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule, true)) { overAgain = true; break;