From 43f2b7441b94fefb93dc9efc8f587b6a2de7e820 Mon Sep 17 00:00:00 2001 From: Maximilian Seidler <78690852+PaideiaDilemma@users.noreply.github.com> Date: Sun, 7 Jul 2024 21:44:53 +0200 Subject: [PATCH] core: handle missing wayland protocol support (#408) * core: check support of wp_factional_scale_manager_v1 and wp_viewporter * core: check support of zwlr_screencopy_manager_v1 --- src/core/LockSurface.cpp | 18 +++++++++++++----- src/renderer/AsyncResourceGatherer.cpp | 17 +++++++++++------ src/renderer/AsyncResourceGatherer.hpp | 1 + src/renderer/Renderer.cpp | 6 ++++++ 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/core/LockSurface.cpp b/src/core/LockSurface.cpp index 162946b..006a2eb 100644 --- a/src/core/LockSurface.cpp +++ b/src/core/LockSurface.cpp @@ -53,12 +53,20 @@ CSessionLockSurface::CSessionLockSurface(COutput* output) : output(output) { exit(1); } - fractional = wp_fractional_scale_manager_v1_get_fractional_scale(g_pHyprlock->getFractionalMgr(), surface); - if (fractional) { - wp_fractional_scale_v1_add_listener(fractional, &fsListener, this); - viewport = wp_viewporter_get_viewport(g_pHyprlock->getViewporter(), surface); - } else + const auto PFRACTIONALMGR = g_pHyprlock->getFractionalMgr(); + const auto PVIEWPORTER = g_pHyprlock->getViewporter(); + if (PFRACTIONALMGR && PVIEWPORTER) { + fractional = wp_fractional_scale_manager_v1_get_fractional_scale(PFRACTIONALMGR, surface); + if (fractional) { + wp_fractional_scale_v1_add_listener(fractional, &fsListener, this); + viewport = wp_viewporter_get_viewport(PVIEWPORTER, surface); + } + } + + if (!PFRACTIONALMGR || !fractional) Debug::log(LOG, "No fractional-scale support! Oops, won't be able to scale!"); + if (!PVIEWPORTER) + Debug::log(LOG, "No viewporter support! Oops, won't be able to scale!"); lockSurface = ext_session_lock_v1_get_lock_surface(g_pHyprlock->getSessionLock(), surface, output->output); diff --git a/src/renderer/AsyncResourceGatherer.cpp b/src/renderer/AsyncResourceGatherer.cpp index df98349..e43392a 100644 --- a/src/renderer/AsyncResourceGatherer.cpp +++ b/src/renderer/AsyncResourceGatherer.cpp @@ -12,6 +12,17 @@ #include "../helpers/Webp.hpp" CAsyncResourceGatherer::CAsyncResourceGatherer() { + if (g_pHyprlock->getScreencopy()) + enqueueDMAFrames(); + + initialGatherThread = std::thread([this]() { this->gather(); }); + initialGatherThread.detach(); + + asyncLoopThread = std::thread([this]() { this->asyncAssetSpinLock(); }); + asyncLoopThread.detach(); +} + +void CAsyncResourceGatherer::enqueueDMAFrames() { // some things can't be done async :( // gather background textures when needed @@ -48,12 +59,6 @@ CAsyncResourceGatherer::CAsyncResourceGatherer() { dmas.emplace_back(std::make_unique(PMONITOR)); } - - initialGatherThread = std::thread([this]() { this->gather(); }); - initialGatherThread.detach(); - - asyncLoopThread = std::thread([this]() { this->asyncAssetSpinLock(); }); - asyncLoopThread.detach(); } SPreloadedAsset* CAsyncResourceGatherer::getAssetByID(const std::string& id) { diff --git a/src/renderer/AsyncResourceGatherer.hpp b/src/renderer/AsyncResourceGatherer.hpp index 19defd3..ff4bb5d 100644 --- a/src/renderer/AsyncResourceGatherer.hpp +++ b/src/renderer/AsyncResourceGatherer.hpp @@ -86,4 +86,5 @@ class CAsyncResourceGatherer { std::unordered_map assets; void gather(); + void enqueueDMAFrames(); }; diff --git a/src/renderer/Renderer.cpp b/src/renderer/Renderer.cpp index 560ceae..26fae5d 100644 --- a/src/renderer/Renderer.cpp +++ b/src/renderer/Renderer.cpp @@ -331,6 +331,12 @@ std::vector>* CRenderer::getOrCreateWidgetsFor(const CS if (!asyncResourceGatherer->getAssetByID(resourceID)) resourceID = ""; // Fallback to solid color (background:color) } + + if (!g_pHyprlock->getScreencopy()) { + Debug::log(ERR, "No screencopy support! path=screenshot won't work. Falling back to background color."); + resourceID = ""; + } + } else if (!PATH.empty()) resourceID = "background:" + PATH;