From be03497b82be332a124dd170e8741623791ef7c4 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Mon, 2 Mar 2026 21:39:06 +0000 Subject: layout/algos: use binds:window_direction_monitor_fallback for moves (#13508) ref https://github.com/hyprwm/Hyprland/discussions/13473 --- src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp | 9 +++++++-- src/layout/algorithm/tiled/master/MasterAlgorithm.cpp | 7 ++++++- src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp | 5 +++++ src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp | 8 +++++++- 4 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src/layout/algorithm/tiled') diff --git a/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp b/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp index 1c8c43a7..17ddfe8a 100644 --- a/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp +++ b/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp @@ -549,6 +549,8 @@ std::optional CDwindleAlgorithm::predictSizeForNewTarget() { } void CDwindleAlgorithm::moveTargetInDirection(SP t, Math::eDirection dir, bool silent) { + static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); + const auto PNODE = getNodeFromTarget(t); const Vector2D originalPos = t->position().middle(); @@ -557,12 +559,15 @@ void CDwindleAlgorithm::moveTargetInDirection(SP t, Math::eDirection di const auto FOCAL_POINT = focalPointForDir(t, dir); + const auto PMONITORFOCAL = g_pCompositor->getMonitorFromVector(FOCAL_POINT.value_or(t->position().middle())); + + if (PMONITORFOCAL != m_parent->space()->workspace()->m_monitor && !*PMONITORFALLBACK) + return; // noop + t->window()->setAnimationsToMove(); removeTarget(t); - 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 diff --git a/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp b/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp index 88540d20..f2914a46 100644 --- a/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp +++ b/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp @@ -403,7 +403,9 @@ void CMasterAlgorithm::swapTargets(SP a, SP b) { } void CMasterAlgorithm::moveTargetInDirection(SP t, Math::eDirection dir, bool silent) { - const auto PWINDOW2 = g_pCompositor->getWindowInDirection(t->window(), dir); + static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); + + const auto PWINDOW2 = g_pCompositor->getWindowInDirection(t->window(), dir); if (!t->window()) return; @@ -424,6 +426,9 @@ void CMasterAlgorithm::moveTargetInDirection(SP t, Math::eDirection dir t->window()->setAnimationsToMove(); if (t->window()->m_workspace != targetWs) { + if (!*PMONITORFALLBACK) + return; // noop + t->assignToSpace(targetWs->m_space, focalPointForDir(t, dir)); } else if (PWINDOW2) { // if same monitor, switch windows diff --git a/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp b/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp index 3551b370..fe92f27c 100644 --- a/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp +++ b/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp @@ -202,6 +202,11 @@ void CMonocleAlgorithm::swapTargets(SP a, SP b) { } void CMonocleAlgorithm::moveTargetInDirection(SP t, Math::eDirection dir, bool silent) { + static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); + + if (!*PMONITORFALLBACK) + return; // noop + // try to find a monitor in the specified direction, thats the logical thing if (!t || !t->space() || !t->space()->workspace()) return; diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp index 3b5dca4a..0c3bb1cc 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp @@ -848,7 +848,9 @@ void CScrollingAlgorithm::moveTargetInDirection(SP t, Math::eDirection } void CScrollingAlgorithm::moveTargetTo(SP t, Math::eDirection dir, bool silent) { - const auto DATA = dataFor(t); + static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); + + const auto DATA = dataFor(t); if (!DATA) return; @@ -953,6 +955,10 @@ void CScrollingAlgorithm::moveTargetTo(SP t, Math::eDirection dir, bool if (!commenceDir()) { // dir wasn't commenced, move to a workspace if possible // with the original dir + + if (!*PMONITORFALLBACK) + return; // noop + const auto MONINDIR = g_pCompositor->getMonitorInDirection(m_parent->space()->workspace()->m_monitor.lock(), dir); if (MONINDIR && MONINDIR != m_parent->space()->workspace()->m_monitor && MONINDIR->m_activeWorkspace) { t->assignToSpace(MONINDIR->m_activeWorkspace->m_space, focalPointForDir(t, dir)); -- cgit v1.2.3