diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index cb6bd264f..94a362de9 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1118,7 +1118,7 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SPm_xdgSurface->m_current.geometry; - // ignore X and Y, adjust uv - if (geom.x != 0 || geom.y != 0 || geom.width > projSizeUnscaled.x || geom.height > projSizeUnscaled.y) { + // Adjust UV based on the xdg_surface geometry + if (geom.x != 0 || geom.y != 0 || geom.w != 0 || geom.h != 0) { const auto XPERC = (double)geom.x / (double)pSurface->m_current.size.x; const auto YPERC = (double)geom.y / (double)pSurface->m_current.size.y; - const auto WPERC = (double)(geom.x + geom.width) / (double)pSurface->m_current.size.x; - const auto HPERC = (double)(geom.y + geom.height) / (double)pSurface->m_current.size.y; + const auto WPERC = (double)(geom.x + geom.w ? geom.w : pSurface->m_current.size.x) / (double)pSurface->m_current.size.x; + const auto HPERC = (double)(geom.y + geom.h ? geom.h : pSurface->m_current.size.y) / (double)pSurface->m_current.size.y; const auto TOADDTL = Vector2D(XPERC * (uvBR.x - uvTL.x), YPERC * (uvBR.y - uvTL.y)); uvBR = uvBR - Vector2D((1.0 - WPERC) * (uvBR.x - uvTL.x), (1.0 - HPERC) * (uvBR.y - uvTL.y)); uvTL = uvTL + TOADDTL; + } + // Adjust UV based on our animation progress + if (pSurface->m_current.size.x > projSizeUnscaled.x || pSurface->m_current.size.y > projSizeUnscaled.y) { auto maxSize = projSizeUnscaled; if (pWindow->m_wlSurface->small() && !pWindow->m_wlSurface->m_fillIgnoreSmall) maxSize = pWindow->m_wlSurface->getViewporterCorrectedSize(); - if (geom.width > maxSize.x) - uvBR.x = uvBR.x * (maxSize.x / geom.width); - if (geom.height > maxSize.y) - uvBR.y = uvBR.y * (maxSize.y / geom.height); + if (pSurface->m_current.size.x > maxSize.x) + uvBR.x = uvBR.x * (maxSize.x / pSurface->m_current.size.x); + if (pSurface->m_current.size.y > maxSize.y) + uvBR.y = uvBR.y * (maxSize.y / pSurface->m_current.size.y); } g_pHyprOpenGL->m_renderData.primarySurfaceUVTopLeft = uvTL;