From 2448774de3532e8fdc65b329831ff37208e20f38 Mon Sep 17 00:00:00 2001 From: bvr-yr <130279855+bvr-yr@users.noreply.github.com> Date: Sun, 24 Mar 2024 00:06:54 +0300 Subject: [PATCH] config: allow mon description for `monitor` value (#216) * config: allow mon description for `monitor` value * rename field --- src/core/Output.cpp | 7 ++++--- src/core/Output.hpp | 3 ++- src/renderer/AsyncResourceGatherer.cpp | 5 +++-- src/renderer/Renderer.cpp | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/Output.cpp b/src/core/Output.cpp index fe9a998..2282e5c 100644 --- a/src/core/Output.cpp +++ b/src/core/Output.cpp @@ -46,8 +46,9 @@ static void handleName(void* data, wl_output* output, const char* name) { } static void handleDescription(void* data, wl_output* output, const char* description) { - const auto POUTPUT = (COutput*)data; - Debug::log(LOG, "output {} description {}", POUTPUT->name, description ? description : ""); + const auto POUTPUT = (COutput*)data; + POUTPUT->stringDesc = description ? std::string{description} : ""; + Debug::log(LOG, "output {} description {}", POUTPUT->name, POUTPUT->stringDesc); } static const wl_output_listener outputListener = { @@ -61,4 +62,4 @@ static const wl_output_listener outputListener = { COutput::COutput(wl_output* output, uint32_t name) : name(name), output(output) { wl_output_add_listener(output, &outputListener, this); -} \ No newline at end of file +} diff --git a/src/core/Output.hpp b/src/core/Output.hpp index 5525874..6a0b0e0 100644 --- a/src/core/Output.hpp +++ b/src/core/Output.hpp @@ -16,10 +16,11 @@ class COutput { int scale = 1; std::string stringName = ""; std::string stringPort = ""; + std::string stringDesc = ""; std::unique_ptr sessionLockSurface; wl_output* output = nullptr; private: -}; \ No newline at end of file +}; diff --git a/src/renderer/AsyncResourceGatherer.cpp b/src/renderer/AsyncResourceGatherer.cpp index ae6e773..df0b2b3 100644 --- a/src/renderer/AsyncResourceGatherer.cpp +++ b/src/renderer/AsyncResourceGatherer.cpp @@ -42,7 +42,8 @@ CAsyncResourceGatherer::CAsyncResourceGatherer() { } for (auto& mon : mons) { - const auto MON = std::find_if(g_pHyprlock->m_vOutputs.begin(), g_pHyprlock->m_vOutputs.end(), [mon](const auto& other) { return other->stringPort == mon; }); + const auto MON = std::find_if(g_pHyprlock->m_vOutputs.begin(), g_pHyprlock->m_vOutputs.end(), + [mon](const auto& other) { return other->stringPort == mon || other->stringDesc.starts_with(mon); }); if (MON == g_pHyprlock->m_vOutputs.end()) continue; @@ -65,7 +66,7 @@ void CAsyncResourceGatherer::recheckDMAFramesFor(COutput* output) { if (std::string{std::any_cast(c.values.at("path"))} != "screenshot") continue; - if (c.monitor.empty() || c.monitor == output->stringPort) { + if (c.monitor.empty() || c.monitor == output->stringPort || output->stringDesc.starts_with(c.monitor)) { shouldMake = true; break; } diff --git a/src/renderer/Renderer.cpp b/src/renderer/Renderer.cpp index d661e08..e568bc6 100644 --- a/src/renderer/Renderer.cpp +++ b/src/renderer/Renderer.cpp @@ -306,7 +306,7 @@ std::vector>* CRenderer::getOrCreateWidgetsFor(const CS const auto CWIDGETS = g_pConfigManager->getWidgetConfigs(); for (auto& c : CWIDGETS) { - if (!c.monitor.empty() && c.monitor != surf->output->stringPort) + if (!c.monitor.empty() && c.monitor != surf->output->stringPort && !surf->output->stringDesc.starts_with(c.monitor)) continue; // by type