surface/wayland: conform to small surface requirements
do not stretch small surfaces, instead center them if they fit.
This commit is contained in:
parent
bab2f6a664
commit
7f35f33b4c
7 changed files with 74 additions and 12 deletions
|
|
@ -27,12 +27,29 @@ wlr_surface* CWLSurface::wlr() const {
|
|||
return m_pWLRSurface;
|
||||
}
|
||||
|
||||
bool CWLSurface::small() const {
|
||||
if (!m_pOwner || !exists())
|
||||
return false;
|
||||
|
||||
return m_pOwner->m_vReportedSize.x > m_pWLRSurface->current.buffer_width || m_pOwner->m_vReportedSize.y > m_pWLRSurface->current.buffer_height;
|
||||
}
|
||||
|
||||
Vector2D CWLSurface::correctSmallVec() const {
|
||||
if (!m_pOwner || !exists() || !small() || m_bFillIgnoreSmall)
|
||||
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(
|
||||
{}, {INFINITY, INFINITY}) *
|
||||
(m_pOwner->m_vRealSize.vec() / m_pOwner->m_vReportedSize);
|
||||
}
|
||||
|
||||
void CWLSurface::destroy() {
|
||||
if (!m_pWLRSurface)
|
||||
return;
|
||||
|
||||
hyprListener_destroy.removeCallback();
|
||||
m_pWLRSurface->data = nullptr;
|
||||
m_pOwner = nullptr;
|
||||
|
||||
if (g_pCompositor->m_pLastFocus == m_pWLRSurface)
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue