From f13daf61c797cee7cf2ded07b3e72347ab39d84e Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 20 Sep 2025 01:28:35 +0100 Subject: [PATCH 1/6] renderer: fix uv calculations once and for all fixes synchronization of ackd sizes, fixes wrong xdg stuff --- src/desktop/WLSurface.cpp | 5 ++- src/desktop/Window.cpp | 2 +- src/events/Windows.cpp | 10 +++++- src/protocols/types/SurfaceState.hpp | 4 +++ src/render/Renderer.cpp | 48 ++++++++++++++++------------ 5 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/desktop/WLSurface.cpp b/src/desktop/WLSurface.cpp index d868e1a90a1..a7b7495d2b7 100644 --- a/src/desktop/WLSurface.cpp +++ b/src/desktop/WLSurface.cpp @@ -64,7 +64,10 @@ bool CWLSurface::small() const { const auto O = m_windowOwner.lock(); - return O->m_reportedSize.x > m_resource->m_current.size.x + 1 || O->m_reportedSize.y > m_resource->m_current.size.y + 1; + if (O->m_isX11) + return O->m_reportedSize.x > m_resource->m_current.size.x + 1 || O->m_reportedSize.y > m_resource->m_current.size.y + 1; + else + return m_resource->m_current.ackedSize.x > m_resource->m_current.size.x + 1 || m_resource->m_current.ackedSize.y > m_resource->m_current.size.y + 1; } Vector2D CWLSurface::correctSmallVec() const { diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 71b78dedf05..901be5bf83c 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -1805,7 +1805,7 @@ void CWindow::sendWindowSize(bool force) { if (m_isX11 && m_xwaylandSurface) m_xwaylandSurface->configure({REPORTPOS, REPORTSIZE}); else if (m_xdgSurface && m_xdgSurface->m_toplevel) - m_pendingSizeAcks.emplace_back(m_xdgSurface->m_toplevel->setSize(REPORTSIZE), REPORTPOS.floor()); + m_pendingSizeAcks.emplace_back(m_xdgSurface->m_toplevel->setSize(REPORTSIZE), REPORTSIZE.floor()); } NContentType::eContentType CWindow::getContentType() { diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 7d3eb3eb04e..e2c94316ee8 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -868,7 +868,15 @@ void Events::listener_commitWindow(void* owner, void* data) { if (!PWINDOW->m_isMapped || PWINDOW->isHidden()) return; - PWINDOW->m_reportedSize = PWINDOW->m_pendingReportedSize; // apply pending size. We pinged, the window ponged. + if (PWINDOW->m_pendingSizeAck) { + if (PWINDOW->m_isX11) + PWINDOW->m_reportedSize = PWINDOW->m_pendingSizeAck->second; + else { + PWINDOW->m_wlSurface->resource()->m_pending.ackedSize = PWINDOW->m_pendingSizeAck->second; // apply pending size. We pinged, the window ponged. + PWINDOW->m_wlSurface->resource()->m_pending.updated.bits.acked = true; + PWINDOW->m_pendingSizeAck.reset(); + } + } if (!PWINDOW->m_isX11 && !PWINDOW->isFullscreen() && PWINDOW->m_isFloating) { const auto MINSIZE = PWINDOW->m_xdgSurface->m_toplevel->layoutMinSize(); diff --git a/src/protocols/types/SurfaceState.hpp b/src/protocols/types/SurfaceState.hpp index e11692cf6dd..eb50a98828e 100644 --- a/src/protocols/types/SurfaceState.hpp +++ b/src/protocols/types/SurfaceState.hpp @@ -20,6 +20,7 @@ struct SSurfaceState { bool offset : 1; bool viewport : 1; bool acquire : 1; + bool acked : 1; } bits; } updated; @@ -37,6 +38,9 @@ struct SSurfaceState { Vector2D size, bufferSize; Vector2D offset; + // for xdg_shell resizing + Vector2D ackedSize; + // viewporter protocol surface state struct { bool hasDestination = false; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 7efaed0e514..cf07c15990f 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1127,10 +1127,12 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SPm_current.viewport.hasDestination ? pSurface->m_current.viewport.destination : pSurface->m_current.bufferSize / pSurface->m_current.scale) * pMonitor->m_scale) .round(); - if (!SCALE_UNAWARE && (EXPECTED_SIZE.x < projSize.x || EXPECTED_SIZE.y < projSize.y)) { + + const auto RATIO = projSize / EXPECTED_SIZE; + if (!SCALE_UNAWARE && (RATIO.x > 1 || RATIO.y > 1)) { // this will not work with shm AFAIK, idk why. // NOTE: this math is wrong if we have a source... or geom updates later, but I don't think we can do much - const auto FIX = (projSize / EXPECTED_SIZE).clamp(Vector2D{1, 1}, Vector2D{1000000, 1000000}); + const auto FIX = RATIO.clamp(Vector2D{1, 1}, Vector2D{1000000, 1000000}); uvBR = uvBR * FIX; } } @@ -1147,31 +1149,37 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SPm_xdgSurface->m_current.geometry; + // FIXME: this doesn't work. We always set MAXIMIZED anyways, so this doesn't need to work, but it's problematic. - // Adjust UV based on the xdg_surface geometry - if (geom.x != 0 || geom.y != 0 || geom.w != 0 || geom.h != 0) { - const auto XPERC = geom.x / pSurface->m_current.size.x; - const auto YPERC = geom.y / pSurface->m_current.size.y; - const auto WPERC = (geom.x + geom.w ? geom.w : pSurface->m_current.size.x) / pSurface->m_current.size.x; - const auto HPERC = (geom.y + geom.h ? geom.h : pSurface->m_current.size.y) / pSurface->m_current.size.y; + // CBox geom = pWindow->m_xdgSurface->m_current.geometry; - 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 the xdg_surface geometry + // if (geom.x != 0 || geom.y != 0 || geom.w != 0 || geom.h != 0) { + // const auto XPERC = geom.x / pSurface->m_current.size.x; + // const auto YPERC = geom.y / pSurface->m_current.size.y; + // const auto WPERC = (geom.x + geom.w ? geom.w : pSurface->m_current.size.x) / pSurface->m_current.size.x; + // const auto HPERC = (geom.y + geom.h ? geom.h : pSurface->m_current.size.y) / pSurface->m_current.size.y; - // 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; + // 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; + // } + + // Only for clamping: extend edges is done before + { + auto maxSize = ((pSurface->m_current.viewport.hasDestination ? pSurface->m_current.viewport.destination : pSurface->m_current.bufferSize / pSurface->m_current.scale) * + pMonitor->m_scale) + .round(); if (pWindow->m_wlSurface->small() && !pWindow->m_wlSurface->m_fillIgnoreSmall) maxSize = pWindow->m_wlSurface->getViewporterCorrectedSize(); - 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); + const auto RATIO = projSize / maxSize; + + if (RATIO.x < 1.F) + uvBR.x = uvBR.x * RATIO.x; + if (RATIO.y < 1.F) + uvBR.y = uvBR.y * RATIO.y; } g_pHyprOpenGL->m_renderData.primarySurfaceUVTopLeft = uvTL; From 0d9fddca3d39c82806ac0bb7c69e37f90d6398e2 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 20 Sep 2025 16:09:18 +0100 Subject: [PATCH 2/6] fixes --- src/desktop/WLSurface.cpp | 8 +++----- src/desktop/Window.cpp | 8 ++++++++ src/desktop/Window.hpp | 1 + src/protocols/types/SurfaceState.cpp | 3 +++ src/render/Renderer.cpp | 24 +++++++++++++++--------- src/render/pass/SurfacePassElement.cpp | 22 +++++++++++++--------- 6 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/desktop/WLSurface.cpp b/src/desktop/WLSurface.cpp index a7b7495d2b7..427d7fa0c4e 100644 --- a/src/desktop/WLSurface.cpp +++ b/src/desktop/WLSurface.cpp @@ -62,12 +62,10 @@ bool CWLSurface::small() const { if (!m_resource->m_current.texture) return false; - const auto O = m_windowOwner.lock(); + const auto O = m_windowOwner.lock(); + const auto REPORTED_SIZE = O->getReportedSize(); - if (O->m_isX11) - return O->m_reportedSize.x > m_resource->m_current.size.x + 1 || O->m_reportedSize.y > m_resource->m_current.size.y + 1; - else - return m_resource->m_current.ackedSize.x > m_resource->m_current.size.x + 1 || m_resource->m_current.ackedSize.y > m_resource->m_current.size.y + 1; + return REPORTED_SIZE.x > m_resource->m_current.size.x + 1 || REPORTED_SIZE.y > m_resource->m_current.size.y + 1; } Vector2D CWLSurface::correctSmallVec() const { diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 901be5bf83c..d3914203ea8 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -1910,3 +1910,11 @@ SP CWindow::getSolitaryResource() { return nullptr; } + +Vector2D CWindow::getReportedSize() { + if (m_isX11) + return m_reportedSize; + if (m_wlSurface && m_wlSurface->resource()) + return m_wlSurface->resource()->m_current.ackedSize; + return m_reportedSize; +} diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 9d94baeadb8..e08dd7af77e 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -416,6 +416,7 @@ class CWindow { PHLWINDOW parent(); bool priorityFocus(); SP getSolitaryResource(); + Vector2D getReportedSize(); CBox getWindowMainSurfaceBox() const { return {m_realPosition->value().x, m_realPosition->value().y, m_realSize->value().x, m_realSize->value().y}; diff --git a/src/protocols/types/SurfaceState.cpp b/src/protocols/types/SurfaceState.cpp index a1195439e6a..a8838170736 100644 --- a/src/protocols/types/SurfaceState.cpp +++ b/src/protocols/types/SurfaceState.cpp @@ -97,4 +97,7 @@ void SSurfaceState::updateFrom(SSurfaceState& ref) { if (ref.updated.bits.acquire) acquire = ref.acquire; + + if (ref.updated.bits.acked) + ackedSize = ref.ackedSize; } diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index cf07c15990f..0c55d517470 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1166,20 +1166,26 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SPm_current.viewport.hasDestination ? pSurface->m_current.viewport.destination : pSurface->m_current.bufferSize / pSurface->m_current.scale) * - pMonitor->m_scale) - .round(); + if (!pSurface->m_current.viewport.hasSource) { + const auto MONITOR_WL_SCALE = std::ceil(pMonitor->m_scale); + const bool SCALE_UNAWARE = MONITOR_WL_SCALE != pSurface->m_current.scale && !pSurface->m_current.viewport.hasDestination; + auto maxSize = + ((pSurface->m_current.viewport.hasDestination ? + pSurface->m_current.viewport.destination : + (pSurface->m_current.viewport.hasSource ? pSurface->m_current.viewport.source.size() : pSurface->m_current.bufferSize) / pSurface->m_current.scale) * + pMonitor->m_scale) + .round(); if (pWindow->m_wlSurface->small() && !pWindow->m_wlSurface->m_fillIgnoreSmall) maxSize = pWindow->m_wlSurface->getViewporterCorrectedSize(); const auto RATIO = projSize / maxSize; - - if (RATIO.x < 1.F) - uvBR.x = uvBR.x * RATIO.x; - if (RATIO.y < 1.F) - uvBR.y = uvBR.y * RATIO.y; + if (!SCALE_UNAWARE && (RATIO.x < 1 || RATIO.y < 1)) { + // this will not work with shm AFAIK, idk why. + // NOTE: this math is wrong if we have a source... or geom updates later, but I don't think we can do much + const auto FIX = RATIO.clamp(Vector2D{0.0001, 0.0001}, Vector2D{1, 1}); + uvBR = uvBR * FIX; + } } g_pHyprOpenGL->m_renderData.primarySurfaceUVTopLeft = uvTL; diff --git a/src/render/pass/SurfacePassElement.cpp b/src/render/pass/SurfacePassElement.cpp index 7dd423bd49f..7102c76fc83 100644 --- a/src/render/pass/SurfacePassElement.cpp +++ b/src/render/pass/SurfacePassElement.cpp @@ -174,27 +174,31 @@ CBox CSurfacePassElement::getTexBox() { // center the surface if it's smaller than the viewport we assign it if (PSURFACE && !PSURFACE->m_fillIgnoreSmall && PSURFACE->small() /* guarantees PWINDOW */) { - const auto CORRECT = PSURFACE->correctSmallVec(); - const auto SIZE = PSURFACE->getViewporterCorrectedSize(); + const auto CORRECT = PSURFACE->correctSmallVec(); + const auto SIZE = PSURFACE->getViewporterCorrectedSize(); + const auto REPORTED = PWINDOW->getReportedSize(); if (!INTERACTIVERESIZEINPROGRESS) { windowBox.translate(CORRECT); - windowBox.width = SIZE.x * (PWINDOW->m_realSize->value().x / PWINDOW->m_reportedSize.x); - windowBox.height = SIZE.y * (PWINDOW->m_realSize->value().y / PWINDOW->m_reportedSize.y); + windowBox.width = SIZE.x * (PWINDOW->m_realSize->value().x / REPORTED.x); + windowBox.height = SIZE.y * (PWINDOW->m_realSize->value().y / REPORTED.y); } else { windowBox.width = SIZE.x; windowBox.height = SIZE.y; } } - } else { // here we clamp to 2, these might be some tiny specks - windowBox = {sc(outputX) + m_data.pos.x + m_data.localPos.x, sc(outputY) + m_data.pos.y + m_data.localPos.y, - std::max(sc(m_data.surface->m_current.size.x), 2.F), std::max(sc(m_data.surface->m_current.size.y), 2.F)}; + + const auto SURFSIZE = m_data.surface->m_current.viewport.hasSource ? m_data.surface->m_current.viewport.source.size() : m_data.surface->m_current.size; + + windowBox = {sc(outputX) + m_data.pos.x + m_data.localPos.x, sc(outputY) + m_data.pos.y + m_data.localPos.y, std::max(sc(SURFSIZE.x), 2.F), + std::max(sc(SURFSIZE.y), 2.F)}; if (m_data.pWindow && m_data.pWindow->m_realSize->isBeingAnimated() && m_data.surface && !m_data.mainSurface && m_data.squishOversized /* subsurface */) { // adjust subsurfaces to the window - windowBox.width = (windowBox.width / m_data.pWindow->m_reportedSize.x) * m_data.pWindow->m_realSize->value().x; - windowBox.height = (windowBox.height / m_data.pWindow->m_reportedSize.y) * m_data.pWindow->m_realSize->value().y; + const auto REPORTED = m_data.pWindow->getReportedSize(); + windowBox.width = (windowBox.width / REPORTED.x) * m_data.pWindow->m_realSize->value().x; + windowBox.height = (windowBox.height / REPORTED.y) * m_data.pWindow->m_realSize->value().y; } } From f1fe28f605faa531c37c3e8122e580ae9b1946bb Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 20 Sep 2025 16:32:02 +0100 Subject: [PATCH 3/6] fix --- src/desktop/Window.cpp | 15 ++++++++++++++- src/events/Windows.cpp | 11 +++-------- src/render/pass/SurfacePassElement.cpp | 8 +++++--- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index d3914203ea8..58b5cfabb3b 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -16,6 +16,7 @@ #include "../managers/TokenManager.hpp" #include "../managers/animation/AnimationManager.hpp" #include "../managers/ANRManager.hpp" +#include "../managers/eventLoop/EventLoopManager.hpp" #include "../protocols/XDGShell.hpp" #include "../protocols/core/Compositor.hpp" #include "../protocols/core/Subcompositor.hpp" @@ -576,7 +577,12 @@ void CWindow::onMap() { if (!m_isMapped || isX11OverrideRedirect()) return; - sendWindowSize(); + g_pEventLoopManager->doLater([this, self = m_self] { + if (!self) + return; + + sendWindowSize(); + }); }, false); @@ -1556,6 +1562,13 @@ void CWindow::onAck(uint32_t serial) { m_pendingSizeAck = *SERIAL; std::erase_if(m_pendingSizeAcks, [&](const auto& el) { return el.first <= SERIAL->first; }); + + if (m_isX11) + return; + + m_wlSurface->resource()->m_pending.ackedSize = m_pendingSizeAck->second; // apply pending size. We pinged, the window ponged. + m_wlSurface->resource()->m_pending.updated.bits.acked = true; + m_pendingSizeAck.reset(); } void CWindow::onResourceChangeX11() { diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index e2c94316ee8..080b66765c5 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -868,14 +868,9 @@ void Events::listener_commitWindow(void* owner, void* data) { if (!PWINDOW->m_isMapped || PWINDOW->isHidden()) return; - if (PWINDOW->m_pendingSizeAck) { - if (PWINDOW->m_isX11) - PWINDOW->m_reportedSize = PWINDOW->m_pendingSizeAck->second; - else { - PWINDOW->m_wlSurface->resource()->m_pending.ackedSize = PWINDOW->m_pendingSizeAck->second; // apply pending size. We pinged, the window ponged. - PWINDOW->m_wlSurface->resource()->m_pending.updated.bits.acked = true; - PWINDOW->m_pendingSizeAck.reset(); - } + if (PWINDOW->m_pendingSizeAck && PWINDOW->m_isX11) { + PWINDOW->m_reportedSize = PWINDOW->m_pendingSizeAck->second; + PWINDOW->m_pendingSizeAck.reset(); } if (!PWINDOW->m_isX11 && !PWINDOW->isFullscreen() && PWINDOW->m_isFloating) { diff --git a/src/render/pass/SurfacePassElement.cpp b/src/render/pass/SurfacePassElement.cpp index 7102c76fc83..47ace78977a 100644 --- a/src/render/pass/SurfacePassElement.cpp +++ b/src/render/pass/SurfacePassElement.cpp @@ -190,15 +190,17 @@ CBox CSurfacePassElement::getTexBox() { } } else { // here we clamp to 2, these might be some tiny specks - const auto SURFSIZE = m_data.surface->m_current.viewport.hasSource ? m_data.surface->m_current.viewport.source.size() : m_data.surface->m_current.size; + const auto SURFSIZE = m_data.surface->m_current.size; windowBox = {sc(outputX) + m_data.pos.x + m_data.localPos.x, sc(outputY) + m_data.pos.y + m_data.localPos.y, std::max(sc(SURFSIZE.x), 2.F), std::max(sc(SURFSIZE.y), 2.F)}; if (m_data.pWindow && m_data.pWindow->m_realSize->isBeingAnimated() && m_data.surface && !m_data.mainSurface && m_data.squishOversized /* subsurface */) { // adjust subsurfaces to the window const auto REPORTED = m_data.pWindow->getReportedSize(); - windowBox.width = (windowBox.width / REPORTED.x) * m_data.pWindow->m_realSize->value().x; - windowBox.height = (windowBox.height / REPORTED.y) * m_data.pWindow->m_realSize->value().y; + if (REPORTED.x != 0 && REPORTED.y != 0) { + windowBox.width = (windowBox.width / REPORTED.x) * m_data.pWindow->m_realSize->value().x; + windowBox.height = (windowBox.height / REPORTED.y) * m_data.pWindow->m_realSize->value().y; + } } } From 75dfe57de80179c64117754267ab182fd15586e7 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 20 Sep 2025 22:20:35 +0100 Subject: [PATCH 4/6] e --- src/desktop/WLSurface.cpp | 3 ++- src/desktop/Window.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/desktop/WLSurface.cpp b/src/desktop/WLSurface.cpp index 427d7fa0c4e..1a1bd293382 100644 --- a/src/desktop/WLSurface.cpp +++ b/src/desktop/WLSurface.cpp @@ -74,8 +74,9 @@ Vector2D CWLSurface::correctSmallVec() const { const auto SIZE = getViewporterCorrectedSize(); const auto O = m_windowOwner.lock(); + const auto REP = O->getReportedSize(); - return Vector2D{(O->m_reportedSize.x - SIZE.x) / 2, (O->m_reportedSize.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}) * (O->m_realSize->value() / O->m_reportedSize); + return Vector2D{(REP.x - SIZE.x) / 2, (REP.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}) * (O->m_realSize->value() / REP); } Vector2D CWLSurface::correctSmallVecBuf() const { diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 58b5cfabb3b..ba0f09d5c9b 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -1555,7 +1555,7 @@ std::string CWindow::fetchClass() { } void CWindow::onAck(uint32_t serial) { - const auto SERIAL = std::ranges::find_if(m_pendingSizeAcks | std::views::reverse, [serial](const auto& e) { return e.first == serial; }); + const auto SERIAL = std::ranges::find_if(m_pendingSizeAcks | std::views::reverse, [serial](const auto& e) { return e.first <= serial; }); if (SERIAL == m_pendingSizeAcks.rend()) return; From f099ab64bf8a638bacade19a610a61efa5a657e4 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 20 Sep 2025 22:41:09 +0100 Subject: [PATCH 5/6] e2 --- src/render/Renderer.cpp | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 0c55d517470..657a279f85a 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1129,11 +1129,16 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP 1 || RATIO.y > 1)) { - // this will not work with shm AFAIK, idk why. - // NOTE: this math is wrong if we have a source... or geom updates later, but I don't think we can do much - const auto FIX = RATIO.clamp(Vector2D{1, 1}, Vector2D{1000000, 1000000}); - uvBR = uvBR * FIX; + if (!SCALE_UNAWARE) { + if (*PEXPANDEDGES && !SCALE_UNAWARE && (RATIO.x > 1 || RATIO.y > 1)) { + const auto FIX = RATIO.clamp(Vector2D{1, 1}, Vector2D{1000000, 1000000}); + uvBR = uvBR * FIX; + } + + if (RATIO.x < 1 || RATIO.y < 1) { + const auto FIX = RATIO.clamp(Vector2D{0.0001, 0.0001}, Vector2D{1, 1}); + uvBR = uvBR * FIX; + } } } @@ -1165,29 +1170,6 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SPm_current.viewport.hasSource) { - const auto MONITOR_WL_SCALE = std::ceil(pMonitor->m_scale); - const bool SCALE_UNAWARE = MONITOR_WL_SCALE != pSurface->m_current.scale && !pSurface->m_current.viewport.hasDestination; - auto maxSize = - ((pSurface->m_current.viewport.hasDestination ? - pSurface->m_current.viewport.destination : - (pSurface->m_current.viewport.hasSource ? pSurface->m_current.viewport.source.size() : pSurface->m_current.bufferSize) / pSurface->m_current.scale) * - pMonitor->m_scale) - .round(); - - if (pWindow->m_wlSurface->small() && !pWindow->m_wlSurface->m_fillIgnoreSmall) - maxSize = pWindow->m_wlSurface->getViewporterCorrectedSize(); - - const auto RATIO = projSize / maxSize; - if (!SCALE_UNAWARE && (RATIO.x < 1 || RATIO.y < 1)) { - // this will not work with shm AFAIK, idk why. - // NOTE: this math is wrong if we have a source... or geom updates later, but I don't think we can do much - const auto FIX = RATIO.clamp(Vector2D{0.0001, 0.0001}, Vector2D{1, 1}); - uvBR = uvBR * FIX; - } - } - g_pHyprOpenGL->m_renderData.primarySurfaceUVTopLeft = uvTL; g_pHyprOpenGL->m_renderData.primarySurfaceUVBottomRight = uvBR; From 87f6aff44209f5df34a4c065e47186cae314fb06 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 21 Sep 2025 13:08:43 +0100 Subject: [PATCH 6/6] fixed --- src/events/Windows.cpp | 6 ++---- src/render/Renderer.cpp | 13 ++++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 080b66765c5..8f40c0e1816 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -868,10 +868,8 @@ void Events::listener_commitWindow(void* owner, void* data) { if (!PWINDOW->m_isMapped || PWINDOW->isHidden()) return; - if (PWINDOW->m_pendingSizeAck && PWINDOW->m_isX11) { - PWINDOW->m_reportedSize = PWINDOW->m_pendingSizeAck->second; - PWINDOW->m_pendingSizeAck.reset(); - } + if (PWINDOW->m_isX11) + PWINDOW->m_reportedSize = PWINDOW->m_pendingReportedSize; if (!PWINDOW->m_isX11 && !PWINDOW->isFullscreen() && PWINDOW->m_isFloating) { const auto MINSIZE = PWINDOW->m_xdgSurface->m_toplevel->layoutMinSize(); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 657a279f85a..c91abec6f17 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1123,10 +1123,11 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SPm_scale); const bool SCALE_UNAWARE = MONITOR_WL_SCALE != pSurface->m_current.scale && !pSurface->m_current.viewport.hasDestination; - const auto EXPECTED_SIZE = - ((pSurface->m_current.viewport.hasDestination ? pSurface->m_current.viewport.destination : pSurface->m_current.bufferSize / pSurface->m_current.scale) * - pMonitor->m_scale) - .round(); + const auto EXPECTED_SIZE = ((pSurface->m_current.viewport.hasDestination ? + pSurface->m_current.viewport.destination : + (pSurface->m_current.viewport.hasSource ? pSurface->m_current.viewport.source.size() / pSurface->m_current.scale : projSize)) * + pMonitor->m_scale) + .round(); const auto RATIO = projSize / EXPECTED_SIZE; if (!SCALE_UNAWARE) { @@ -1135,7 +1136,9 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SPm_animatingIn; + if (!SHOULD_SKIP && (RATIO.x < 1 || RATIO.y < 1)) { const auto FIX = RATIO.clamp(Vector2D{0.0001, 0.0001}, Vector2D{1, 1}); uvBR = uvBR * FIX; }