From b653ab53a435e92cc00f34771e6823bc59f2f740 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Tue, 4 Aug 2026 13:33:12 +0100 Subject: [PATCH] screencopy: don't send bad transform information over wire (#422) ref hyprwm/hyprland#15714 --- src/portals/Screencopy.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/portals/Screencopy.cpp b/src/portals/Screencopy.cpp index 34af332..372b62b 100644 --- a/src/portals/Screencopy.cpp +++ b/src/portals/Screencopy.cpp @@ -9,6 +9,9 @@ #include #include "linux-dmabuf-v1.hpp" #include +#include + +using namespace Hyprutils::Math; constexpr static int MAX_RETRIES = 10; constexpr static int MAX_DMABUF_RETRIES = 2; @@ -367,11 +370,20 @@ void CScreencopyPortal::SSession::startCopy() { if (selection.type == TYPE_GEOMETRY) { sharingData.frameCallback = makeShared(g_pPortalManager->m_sPortals.screencopy->m_sState.screencopy->sendCaptureOutputRegion( OVERLAYCURSOR, POUTPUT->output->resource(), selection.x, selection.y, selection.w, selection.h)); - sharingData.transform = POUTPUT->transform; + sharingData.transform = WL_OUTPUT_TRANSFORM_NORMAL; } else if (selection.type == TYPE_OUTPUT) { sharingData.frameCallback = makeShared(g_pPortalManager->m_sPortals.screencopy->m_sState.screencopy->sendCaptureOutput(OVERLAYCURSOR, POUTPUT->output->resource())); - sharingData.transform = POUTPUT->transform; + + // Since Hyprland#15714, hyprland will no longer (wrongly) send transformed buffers. If the buffer size matches, let's send normal. + // this is not perfect (180 will be wrong on old hl) but it's the best we can do + // always fall back to new. + const auto SIZE = sharingData.frameInfoSHM.w > 0 ? Vector2D{sc(sharingData.frameInfoSHM.w), sc(sharingData.frameInfoSHM.h)} : + Vector2D{sc(sharingData.frameInfoDMA.w), sc(sharingData.frameInfoDMA.h)}; + if (SIZE.x == POUTPUT->height && SIZE.y == POUTPUT->width) + sharingData.transform = POUTPUT->transform; + else + sharingData.transform = WL_OUTPUT_TRANSFORM_NORMAL; } else if (selection.type == TYPE_WINDOW) { if (!selection.windowHandle) { Debug::log(ERR, "[screencopy] selected invalid window?");