mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-30 02:05:58 +01:00
renderer: respect viewporter dest on base surfaces
This commit is contained in:
parent
6650e4ba85
commit
8991be671f
3 changed files with 17 additions and 6 deletions
|
@ -38,11 +38,20 @@ Vector2D CWLSurface::correctSmallVec() const {
|
||||||
if (!m_pOwner || !exists() || !small() || m_bFillIgnoreSmall)
|
if (!m_pOwner || !exists() || !small() || m_bFillIgnoreSmall)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return Vector2D{(m_pOwner->m_vReportedSize.x - m_pWLRSurface->current.buffer_width) / 2, (m_pOwner->m_vReportedSize.y - m_pWLRSurface->current.buffer_height) / 2}.clamp(
|
const auto SIZE = getViewporterCorrectedSize();
|
||||||
{}, {INFINITY, INFINITY}) *
|
|
||||||
|
return Vector2D{(m_pOwner->m_vReportedSize.x - SIZE.x) / 2, (m_pOwner->m_vReportedSize.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}) *
|
||||||
(m_pOwner->m_vRealSize.vec() / m_pOwner->m_vReportedSize);
|
(m_pOwner->m_vRealSize.vec() / m_pOwner->m_vReportedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2D CWLSurface::getViewporterCorrectedSize() const {
|
||||||
|
if (!exists())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return m_pWLRSurface->current.viewport.has_dst ? Vector2D{m_pWLRSurface->current.viewport.dst_width, m_pWLRSurface->current.viewport.dst_height} :
|
||||||
|
Vector2D{m_pWLRSurface->current.buffer_width, m_pWLRSurface->current.buffer_height};
|
||||||
|
}
|
||||||
|
|
||||||
void CWLSurface::destroy() {
|
void CWLSurface::destroy() {
|
||||||
if (!m_pWLRSurface)
|
if (!m_pWLRSurface)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -22,6 +22,7 @@ class CWLSurface {
|
||||||
bool exists() const;
|
bool exists() const;
|
||||||
bool small() const; // means surface is smaller than the requested size
|
bool small() const; // means surface is smaller than the requested size
|
||||||
Vector2D correctSmallVec() const; // returns a corrective vector for small() surfaces
|
Vector2D correctSmallVec() const; // returns a corrective vector for small() surfaces
|
||||||
|
Vector2D getViewporterCorrectedSize() const;
|
||||||
|
|
||||||
// allow stretching. Useful for plugins.
|
// allow stretching. Useful for plugins.
|
||||||
bool m_bFillIgnoreSmall = false;
|
bool m_bFillIgnoreSmall = false;
|
||||||
|
|
|
@ -31,17 +31,18 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
||||||
|
|
||||||
if (PSURFACE && !PSURFACE->m_bFillIgnoreSmall && PSURFACE->small() /* guarantees m_pOwner */) {
|
if (PSURFACE && !PSURFACE->m_bFillIgnoreSmall && PSURFACE->small() /* guarantees m_pOwner */) {
|
||||||
const auto CORRECT = PSURFACE->correctSmallVec();
|
const auto CORRECT = PSURFACE->correctSmallVec();
|
||||||
|
const auto SIZE = PSURFACE->getViewporterCorrectedSize();
|
||||||
const auto INTERACTIVERESIZEINPROGRESS = g_pInputManager->currentlyDraggedWindow == PSURFACE->m_pOwner && g_pInputManager->dragMode == MBIND_RESIZE;
|
const auto INTERACTIVERESIZEINPROGRESS = g_pInputManager->currentlyDraggedWindow == PSURFACE->m_pOwner && g_pInputManager->dragMode == MBIND_RESIZE;
|
||||||
|
|
||||||
if (!INTERACTIVERESIZEINPROGRESS) {
|
if (!INTERACTIVERESIZEINPROGRESS) {
|
||||||
windowBox.x += CORRECT.x;
|
windowBox.x += CORRECT.x;
|
||||||
windowBox.y += CORRECT.y;
|
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.width = SIZE.x * (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.height = SIZE.y * (PSURFACE->m_pOwner->m_vRealSize.vec().y / PSURFACE->m_pOwner->m_vReportedSize.y);
|
||||||
} else {
|
} else {
|
||||||
windowBox.width = (double)surface->current.buffer_width;
|
windowBox.width = SIZE.x;
|
||||||
windowBox.height = (double)surface->current.buffer_height;
|
windowBox.height = SIZE.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue