From 9fb50252d3a128466e80bfc2fb67b45dc923ad41 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Tue, 26 Dec 2023 19:44:38 +0100 Subject: [PATCH] special: move floating windows along with the workspace --- src/helpers/Monitor.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index ca1318cc..3b4f4016 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -622,6 +622,22 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) { if (w->m_iWorkspaceID == pWorkspace->m_iID) { w->m_iMonitorID = ID; w->updateSurfaceOutputs(); + + const auto MIDDLE = w->middle(); + if (w->m_bIsFloating && !VECINRECT(MIDDLE, vecPosition.x, vecPosition.y, vecPosition.x + vecSize.x, vecPosition.y + vecSize.y) && w->m_iX11Type != 2) { + // if it's floating and the middle isnt on the current mon, move it to the center + const auto PMONFROMMIDDLE = g_pCompositor->getMonitorFromVector(MIDDLE); + Vector2D pos = w->m_vRealPosition.goalv(); + if (!VECINRECT(MIDDLE, PMONFROMMIDDLE->vecPosition.x, PMONFROMMIDDLE->vecPosition.y, PMONFROMMIDDLE->vecPosition.x + PMONFROMMIDDLE->vecSize.x, + PMONFROMMIDDLE->vecPosition.y + PMONFROMMIDDLE->vecSize.y)) { + // not on any monitor, center + pos = middle() / 2.f - w->m_vRealSize.goalv() / 2.f; + } else + pos = pos - PMONFROMMIDDLE->vecPosition + vecPosition; + + w->m_vRealPosition = pos; + w->m_vPosition = pos; + } } }