From 260a13a12f6c9990c029650b615abd41cd2ab4c7 Mon Sep 17 00:00:00 2001 From: Mike Will Date: Fri, 18 Jul 2025 11:35:43 -0400 Subject: snap: use window extents instead of border size (#11079) * snap: use window extents instead of border size `border_overlap` no longer does anything for window snapping, only monitor snapping. --- src/desktop/Window.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/desktop/Window.cpp') diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 8cdb5ceb..ceb21d09 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -236,6 +236,18 @@ CBox CWindow::getWindowIdealBoundingBoxIgnoreReserved() { return CBox{(int)POS.x, (int)POS.y, (int)SIZE.x, (int)SIZE.y}; } +SBoxExtents CWindow::getWindowExtentsUnified(uint64_t properties) { + SBoxExtents extents = {.topLeft = {0, 0}, .bottomRight = {0, 0}}; + if (properties & RESERVED_EXTENTS) + extents.addExtents(g_pDecorationPositioner->getWindowDecorationReserved(m_self.lock())); + if (properties & INPUT_EXTENTS) + extents.addExtents(g_pDecorationPositioner->getWindowDecorationExtents(m_self.lock(), true)); + if (properties & FULL_EXTENTS) + extents.addExtents(g_pDecorationPositioner->getWindowDecorationExtents(m_self.lock(), false)); + + return extents; +} + CBox CWindow::getWindowBoxUnified(uint64_t properties) { if (m_windowData.dimAround.valueOrDefault()) { const auto PMONITOR = m_monitor.lock(); @@ -243,16 +255,8 @@ CBox CWindow::getWindowBoxUnified(uint64_t properties) { return {PMONITOR->m_position.x, PMONITOR->m_position.y, PMONITOR->m_size.x, PMONITOR->m_size.y}; } - SBoxExtents EXTENTS = {.topLeft = {0, 0}, .bottomRight = {0, 0}}; - if (properties & RESERVED_EXTENTS) - EXTENTS.addExtents(g_pDecorationPositioner->getWindowDecorationReserved(m_self.lock())); - if (properties & INPUT_EXTENTS) - EXTENTS.addExtents(g_pDecorationPositioner->getWindowDecorationExtents(m_self.lock(), true)); - if (properties & FULL_EXTENTS) - EXTENTS.addExtents(g_pDecorationPositioner->getWindowDecorationExtents(m_self.lock(), false)); - CBox box = {m_realPosition->value().x, m_realPosition->value().y, m_realSize->value().x, m_realSize->value().y}; - box.addExtents(EXTENTS); + box.addExtents(getWindowExtentsUnified(properties)); return box; } -- cgit v1.2.3