From 30c5911718c02e0215bf0006faa6aa229558a501 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 17 Mar 2024 16:08:54 +0000 Subject: [PATCH] renderer: minor fixups for misaligned surface rendering offsets fixes #5136 --- src/Window.cpp | 3 +++ src/render/Renderer.cpp | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Window.cpp b/src/Window.cpp index c6c958ba..59ad5a3b 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -1058,6 +1058,9 @@ bool CWindow::opaque() { if (m_fAlpha.value() != 1.f || m_fActiveInactiveAlpha.value() != 1.f) return false; + if (m_vRealSize.goal().floor() != m_vReportedSize) + return false; + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID); if (m_pWLSurface.small() && !m_pWLSurface.m_bFillIgnoreSmall) diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 112be432..e2bcbf1e 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -92,10 +92,12 @@ static void renderSurface(struct wlr_surface* surface, int x, int y, void* data) } } - if (!INTERACTIVERESIZEINPROGRESS && PSURFACE && PWINDOW && PWINDOW->m_vRealSize.goal() > PWINDOW->m_vReportedSize && PWINDOW->m_vReportedSize > Vector2D{1, 1}) { - Vector2D size = - Vector2D{windowBox.w * (PWINDOW->m_vReportedSize.x / PWINDOW->m_vRealSize.value().x), windowBox.h * (PWINDOW->m_vReportedSize.y / PWINDOW->m_vRealSize.value().y)}; - Vector2D correct = Vector2D{windowBox.w, windowBox.h} - size; + if (!INTERACTIVERESIZEINPROGRESS && PSURFACE && PWINDOW && PWINDOW->m_vRealSize.goal().floor() > PWINDOW->m_vReportedSize && PWINDOW->m_vReportedSize > Vector2D{1, 1}) { + Vector2D coeff = PWINDOW->m_vReportedSize / PWINDOW->m_vRealSize.value(); + Vector2D coeff2 = PWINDOW->m_vReportedSize / PWINDOW->m_vRealSize.goal(); + + Vector2D size = Vector2D{windowBox.w, windowBox.h} * coeff; + Vector2D correct = Vector2D{windowBox.w, windowBox.h} - Vector2D{windowBox.w, windowBox.h} * coeff2; windowBox.translate(correct / 2.0);