summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2023-12-26 19:44:38 +0100
committervaxerski <vaxry@vaxry.net>2023-12-26 19:44:38 +0100
commit9fb50252d3a128466e80bfc2fb67b45dc923ad41 (patch)
treefb74da95eacd2cfe35412c93e876b57ae105a77c /src
parentbfb4d66c8144a36f2c52530f10ae4bac2ac03b09 (diff)
special: move floating windows along with the workspace
Diffstat (limited to 'src')
-rw-r--r--src/helpers/Monitor.cpp16
1 files changed, 16 insertions, 0 deletions
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;
+ }
}
}