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
This commit is contained in:
Maximilian Seidler 2024-07-07 21:44:53 +02:00 committed by GitHub
parent 0552a1eddd
commit 43f2b7441b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 31 additions and 11 deletions

View file

@ -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);
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(g_pHyprlock->getViewporter(), surface);
} else
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);

View file

@ -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<CDMAFrame>(PMONITOR));
}
initialGatherThread = std::thread([this]() { this->gather(); });
initialGatherThread.detach();
asyncLoopThread = std::thread([this]() { this->asyncAssetSpinLock(); });
asyncLoopThread.detach();
}
SPreloadedAsset* CAsyncResourceGatherer::getAssetByID(const std::string& id) {

View file

@ -86,4 +86,5 @@ class CAsyncResourceGatherer {
std::unordered_map<std::string, SPreloadedAsset> assets;
void gather();
void enqueueDMAFrames();
};

View file

@ -331,6 +331,12 @@ std::vector<std::unique_ptr<IWidget>>* 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;