Skip to content

Commit

Permalink
renderer: fix shimmers when manual resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Oct 20, 2023
1 parent 7f35f33 commit 4a79718
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
auto* const PSURFACE = CWLSurface::surfaceFromWlr(surface);

if (PSURFACE && !PSURFACE->m_bFillIgnoreSmall && PSURFACE->small() /* guarantees m_pOwner */) {
const auto CORRECT = PSURFACE->correctSmallVec();
const auto CORRECT = PSURFACE->correctSmallVec();
const auto INTERACTIVERESIZEINPROGRESS = g_pInputManager->currentlyDraggedWindow == PSURFACE->m_pOwner && g_pInputManager->dragMode == MBIND_RESIZE;

windowBox.x += CORRECT.x;
windowBox.y += CORRECT.y;
if (!INTERACTIVERESIZEINPROGRESS) {
windowBox.x += CORRECT.x;
windowBox.y += CORRECT.y;

windowBox.width = (double)surface->current.buffer_width * (PSURFACE->m_pOwner->m_vRealSize.vec().x / PSURFACE->m_pOwner->m_vReportedSize.x);
windowBox.height = (double)surface->current.buffer_height * (PSURFACE->m_pOwner->m_vRealSize.vec().y / PSURFACE->m_pOwner->m_vReportedSize.y);
windowBox.width = (double)surface->current.buffer_width * (PSURFACE->m_pOwner->m_vRealSize.vec().x / PSURFACE->m_pOwner->m_vReportedSize.x);
windowBox.height = (double)surface->current.buffer_height * (PSURFACE->m_pOwner->m_vRealSize.vec().y / PSURFACE->m_pOwner->m_vReportedSize.y);
} else {
windowBox.width = (double)surface->current.buffer_width;
windowBox.height = (double)surface->current.buffer_height;
}
}

} else { // here we clamp to 2, these might be some tiny specks
Expand Down Expand Up @@ -682,7 +688,7 @@ void CHyprRenderer::calculateUVForSurface(CWindow* pWindow, wlr_surface* pSurfac
wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom);

// ignore X and Y, adjust uv
if (geom.x != 0 || geom.y != 0 || geom.width > pWindow->m_vRealSize.goalv().x || geom.height > pWindow->m_vRealSize.goalv().y) {
if (geom.x != 0 || geom.y != 0 || geom.width > pWindow->m_vRealSize.vec().x || geom.height > pWindow->m_vRealSize.vec().y) {
const auto XPERC = (double)geom.x / (double)pSurface->current.width;
const auto YPERC = (double)geom.y / (double)pSurface->current.height;
const auto WPERC = (double)(geom.x + geom.width) / (double)pSurface->current.width;
Expand All @@ -692,9 +698,9 @@ void CHyprRenderer::calculateUVForSurface(CWindow* pWindow, wlr_surface* pSurfac
uvBR = uvBR - Vector2D(1.0 - WPERC * (uvBR.x - uvTL.x), 1.0 - HPERC * (uvBR.y - uvTL.y));
uvTL = uvTL + TOADDTL;

if (geom.width > pWindow->m_vRealSize.goalv().x || geom.height > pWindow->m_vRealSize.goalv().y) {
uvBR.x = uvBR.x * (pWindow->m_vRealSize.goalv().x / geom.width);
uvBR.y = uvBR.y * (pWindow->m_vRealSize.goalv().y / geom.height);
if (geom.width > pWindow->m_vRealSize.vec().x || geom.height > pWindow->m_vRealSize.vec().y) {
uvBR.x = uvBR.x * (pWindow->m_vRealSize.vec().x / geom.width);
uvBR.y = uvBR.y * (pWindow->m_vRealSize.vec().y / geom.height);
}
}

Expand Down

0 comments on commit 4a79718

Please sign in to comment.