From 7f35f33b4ca16509e127976772db6abd9abf100b Mon Sep 17 00:00:00 2001 From: Vaxry Date: Fri, 20 Oct 2023 20:15:41 +0100 Subject: surface/wayland: conform to small surface requirements do not stretch small surfaces, instead center them if they fit. --- src/render/Renderer.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/render/Renderer.cpp') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index c4daa416..7fe2774b 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -23,9 +23,23 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, RDATA->pMonitor->output, &outputX, &outputY); wlr_box windowBox; - if (RDATA->surface && surface == RDATA->surface) + if (RDATA->surface && surface == RDATA->surface) { windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, RDATA->w, RDATA->h}; - else { // here we clamp to 2, these might be some tiny specks + + // however, if surface buffer w / h < box, we need to adjust them + auto* const PSURFACE = CWLSurface::surfaceFromWlr(surface); + + if (PSURFACE && !PSURFACE->m_bFillIgnoreSmall && PSURFACE->small() /* guarantees m_pOwner */) { + const auto CORRECT = PSURFACE->correctSmallVec(); + + 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); + } + + } else { // here we clamp to 2, these might be some tiny specks windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, std::max(surface->current.width, 2), std::max(surface->current.height, 2)}; if (RDATA->pWindow && RDATA->pWindow->m_vRealSize.isBeingAnimated() && RDATA->surface && RDATA->surface != surface && RDATA->squishOversized /* subsurface */) { // adjust subsurfaces to the window @@ -1392,6 +1406,13 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y, dou if (g_pCompositor->m_bUnsafeState) return; + auto* const PSURFACE = CWLSurface::surfaceFromWlr(pSurface); + if (PSURFACE && PSURFACE->m_pOwner && PSURFACE->small()) { + const auto CORRECTION = PSURFACE->correctSmallVec(); + x += CORRECTION.x; + y += CORRECTION.y; + } + CRegion damageBox; wlr_surface_get_effective_damage(pSurface, damageBox.pixman()); if (scale != 1.0) -- cgit v1.2.3