diff options
| author | Vaxry <vaxry@vaxry.net> | 2023-10-20 20:15:41 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2023-10-20 20:15:57 +0100 |
| commit | 7f35f33b4ca16509e127976772db6abd9abf100b (patch) | |
| tree | 557326d4214617c3459d983001d969fbe6510448 /src/render/Renderer.cpp | |
| parent | bab2f6a664a67dfd0c2f442dbc0134ef7c6e07e2 (diff) | |
surface/wayland: conform to small surface requirements
do not stretch small surfaces, instead center them if they fit.
Diffstat (limited to 'src/render/Renderer.cpp')
| -rw-r--r-- | src/render/Renderer.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
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) |
