From 8d31c84483be7cc6f909d73c6ecd4c0b4bdc3360 Mon Sep 17 00:00:00 2001 From: Clyybber Date: Wed, 10 Jan 2024 18:08:58 +0100 Subject: layout: Round window pos and size on togglefloating (#4407) Also restore the behaviour introduced in bc4a51dbbb285391c9ed45b1b6ca7c2037b7ba71 --- src/layout/IHyprLayout.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/layout/IHyprLayout.cpp') diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 6a03ac80..2a8fdf53 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -469,16 +469,18 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) { g_pCompositor->changeWindowZOrder(pWindow, true); + CBox wb = {pWindow->m_vRealPosition.goalv() + (pWindow->m_vRealSize.goalv() - pWindow->m_vLastFloatingSize) / 2.f, pWindow->m_vLastFloatingSize}; + wb.round(); + if (DELTALESSTHAN(pWindow->m_vRealSize.vec().x, pWindow->m_vLastFloatingSize.x, 10) && DELTALESSTHAN(pWindow->m_vRealSize.vec().y, pWindow->m_vLastFloatingSize.y, 10)) { - pWindow->m_vRealPosition = pWindow->m_vRealPosition.goalv() + (pWindow->m_vRealSize.goalv() - pWindow->m_vLastFloatingSize) / 2.f + Vector2D{10, 10}; - pWindow->m_vRealSize = pWindow->m_vLastFloatingSize - Vector2D{20, 20}; + wb = {wb.pos() + Vector2D{10, 10}, wb.size() - Vector2D{20, 20}}; } - pWindow->m_vRealPosition = pWindow->m_vRealPosition.goalv() + (pWindow->m_vRealSize.goalv() - pWindow->m_vLastFloatingSize) / 2.f; - pWindow->m_vRealSize = pWindow->m_vLastFloatingSize; + pWindow->m_vRealPosition = wb.pos(); + pWindow->m_vRealSize = wb.size(); - pWindow->m_vSize = pWindow->m_vRealSize.goalv(); - pWindow->m_vPosition = pWindow->m_vRealPosition.goalv(); + pWindow->m_vSize = wb.pos(); + pWindow->m_vPosition = wb.size(); g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID)); -- cgit v1.2.3