summaryrefslogtreecommitdiff
path: root/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-03-02 21:10:21 +0000
committerGitHub <noreply@github.com>2026-03-02 21:10:21 +0000
commit75a815fbf28b73f3b9f9b9246ed3eb1fbd9b2a58 (patch)
tree528fa1fdea51f905010034a4228ad74a3c117551 /src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp
parent3b7401b065d78582fe67591f37d36021e94d2f0a (diff)
algo/dwindle: use focal point correctly for x-ws moves (#13514)
Diffstat (limited to 'src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp')
-rw-r--r--src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp37
1 files changed, 12 insertions, 25 deletions
diff --git a/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp b/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp
index 32afc3ab..a1fcf521 100644
--- a/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp
+++ b/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp
@@ -99,11 +99,13 @@ void CDwindleAlgorithm::addTarget(SP<ITarget> target, bool newTarget) {
if (!OPENINGON && g_pCompositor->isPointOnReservedArea(MOUSECOORDS, ACTIVE_MON))
OPENINGON = getClosestNode(MOUSECOORDS);
- } else if (*PUSEACTIVE) {
+ } else if (*PUSEACTIVE || m_overrideFocalPoint) {
const auto ACTIVE_WINDOW = Desktop::focusState()->window();
- if (!m_overrideFocalPoint && ACTIVE_WINDOW && !ACTIVE_WINDOW->m_isFloating && ACTIVE_WINDOW != target->window() && ACTIVE_WINDOW->m_workspace == PWORKSPACE &&
- ACTIVE_WINDOW->m_isMapped)
+ if (m_overrideFocalPoint)
+ OPENINGON = getClosestNode(*m_overrideFocalPoint);
+ else if (!m_overrideFocalPoint && ACTIVE_WINDOW && !ACTIVE_WINDOW->m_isFloating && ACTIVE_WINDOW != target->window() && ACTIVE_WINDOW->m_workspace == PWORKSPACE &&
+ ACTIVE_WINDOW->m_isMapped)
OPENINGON = getNodeFromWindow(ACTIVE_WINDOW);
if (!OPENINGON)
@@ -214,10 +216,7 @@ void CDwindleAlgorithm::addTarget(SP<ITarget> target, bool newTarget) {
}
}
} else if (*PFORCESPLIT == 0 || !newTarget) {
- if ((SIDEBYSIDE &&
- VECINRECT(MOUSECOORDS, NEWPARENT->box.x, NEWPARENT->box.y / *PWIDTHMULTIPLIER, NEWPARENT->box.x + NEWPARENT->box.w / 2.f, NEWPARENT->box.y + NEWPARENT->box.h)) ||
- (!SIDEBYSIDE &&
- VECINRECT(MOUSECOORDS, NEWPARENT->box.x, NEWPARENT->box.y / *PWIDTHMULTIPLIER, NEWPARENT->box.x + NEWPARENT->box.w, NEWPARENT->box.y + NEWPARENT->box.h / 2.f))) {
+ if ((SIDEBYSIDE && MOUSECOORDS.x < NEWPARENT->box.x + (NEWPARENT->box.w / 2.F)) || (!SIDEBYSIDE && MOUSECOORDS.y < NEWPARENT->box.y + (NEWPARENT->box.h / 2.F))) {
// we are hovering over the first node, make PNODE first.
NEWPARENT->children[1] = OPENINGON;
NEWPARENT->children[0] = PNODE;
@@ -242,11 +241,10 @@ void CDwindleAlgorithm::addTarget(SP<ITarget> target, bool newTarget) {
// and update the previous parent if it exists
if (OPENINGON->pParent) {
- if (OPENINGON->pParent->children[0] == OPENINGON) {
+ if (OPENINGON->pParent->children[0] == OPENINGON)
OPENINGON->pParent->children[0] = NEWPARENT;
- } else {
+ else
OPENINGON->pParent->children[1] = NEWPARENT;
- }
}
// Update the children
@@ -557,35 +555,24 @@ void CDwindleAlgorithm::moveTargetInDirection(SP<ITarget> t, Math::eDirection di
if (!PNODE || !t->window())
return;
- Vector2D focalPoint;
-
- const auto WINDOWIDEALBB =
- t->fullscreenMode() != FSMODE_NONE ? m_parent->space()->workspace()->m_monitor->logicalBox() : t->window()->getWindowIdealBoundingBoxIgnoreReserved();
-
- switch (dir) {
- case Math::DIRECTION_UP: focalPoint = WINDOWIDEALBB.pos() + Vector2D{WINDOWIDEALBB.size().x / 2.0, -1.0}; break;
- case Math::DIRECTION_DOWN: focalPoint = WINDOWIDEALBB.pos() + Vector2D{WINDOWIDEALBB.size().x / 2.0, WINDOWIDEALBB.size().y + 1.0}; break;
- case Math::DIRECTION_LEFT: focalPoint = WINDOWIDEALBB.pos() + Vector2D{-1.0, WINDOWIDEALBB.size().y / 2.0}; break;
- case Math::DIRECTION_RIGHT: focalPoint = WINDOWIDEALBB.pos() + Vector2D{WINDOWIDEALBB.size().x + 1.0, WINDOWIDEALBB.size().y / 2.0}; break;
- default: return;
- }
+ const auto FOCAL_POINT = focalPointForDir(t, dir);
t->window()->setAnimationsToMove();
removeTarget(t);
- const auto PMONITORFOCAL = g_pCompositor->getMonitorFromVector(focalPoint);
+ const auto PMONITORFOCAL = g_pCompositor->getMonitorFromVector(FOCAL_POINT.value_or(t->position().middle()));
if (PMONITORFOCAL != m_parent->space()->workspace()->m_monitor) {
// move with a focal point
if (PMONITORFOCAL->m_activeWorkspace)
- t->assignToSpace(PMONITORFOCAL->m_activeWorkspace->m_space);
+ t->assignToSpace(PMONITORFOCAL->m_activeWorkspace->m_space, FOCAL_POINT);
return;
}
- movedTarget(t, focalPoint);
+ movedTarget(t, FOCAL_POINT);
// restore focus to the previous position
if (silent) {