summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-03-02 21:39:06 +0000
committerGitHub <noreply@github.com>2026-03-02 21:39:06 +0000
commitbe03497b82be332a124dd170e8741623791ef7c4 (patch)
tree06758f08e32a6647d43f70184be40fa1a1024074 /src
parentff20cbf89c68a87b12c0cd3453ac13d7c7197da5 (diff)
layout/algos: use binds:window_direction_monitor_fallback for moves (#13508)
ref https://github.com/hyprwm/Hyprland/discussions/13473
Diffstat (limited to 'src')
-rw-r--r--src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp9
-rw-r--r--src/layout/algorithm/tiled/master/MasterAlgorithm.cpp7
-rw-r--r--src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp5
-rw-r--r--src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp8
-rw-r--r--src/managers/KeybindManager.cpp12
5 files changed, 32 insertions, 9 deletions
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<Vector2D> CDwindleAlgorithm::predictSizeForNewTarget() {
}
void CDwindleAlgorithm::moveTargetInDirection(SP<ITarget> t, Math::eDirection dir, bool silent) {
+ static auto PMONITORFALLBACK = CConfigValue<Hyprlang::INT>("binds:window_direction_monitor_fallback");
+
const auto PNODE = getNodeFromTarget(t);
const Vector2D originalPos = t->position().middle();
@@ -557,12 +559,15 @@ void CDwindleAlgorithm::moveTargetInDirection(SP<ITarget> 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<ITarget> a, SP<ITarget> b) {
}
void CMasterAlgorithm::moveTargetInDirection(SP<ITarget> t, Math::eDirection dir, bool silent) {
- const auto PWINDOW2 = g_pCompositor->getWindowInDirection(t->window(), dir);
+ static auto PMONITORFALLBACK = CConfigValue<Hyprlang::INT>("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<ITarget> 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<ITarget> a, SP<ITarget> b) {
}
void CMonocleAlgorithm::moveTargetInDirection(SP<ITarget> t, Math::eDirection dir, bool silent) {
+ static auto PMONITORFALLBACK = CConfigValue<Hyprlang::INT>("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<ITarget> t, Math::eDirection
}
void CScrollingAlgorithm::moveTargetTo(SP<ITarget> t, Math::eDirection dir, bool silent) {
- const auto DATA = dataFor(t);
+ static auto PMONITORFALLBACK = CConfigValue<Hyprlang::INT>("binds:window_direction_monitor_fallback");
+
+ const auto DATA = dataFor(t);
if (!DATA)
return;
@@ -953,6 +955,10 @@ void CScrollingAlgorithm::moveTargetTo(SP<ITarget> 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));
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 1640efc3..c9c512ae 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -1468,9 +1468,10 @@ SDispatchResult CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
}
SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
- static auto PFULLCYCLE = CConfigValue<Hyprlang::INT>("binds:movefocus_cycles_fullscreen");
- static auto PGROUPCYCLE = CConfigValue<Hyprlang::INT>("binds:movefocus_cycles_groupfirst");
- Math::eDirection dir = Math::fromChar(args[0]);
+ static auto PFULLCYCLE = CConfigValue<Hyprlang::INT>("binds:movefocus_cycles_fullscreen");
+ static auto PGROUPCYCLE = CConfigValue<Hyprlang::INT>("binds:movefocus_cycles_groupfirst");
+ static auto PMONITORFALLBACK = CConfigValue<Hyprlang::INT>("binds:window_direction_monitor_fallback");
+ Math::eDirection dir = Math::fromChar(args[0]);
if (dir == Math::DIRECTION_DEFAULT) {
Log::logger->log(Log::ERR, "Cannot move focus in direction {}, unsupported direction. Supported: l,r,u/t,d/b", args[0]);
@@ -1479,7 +1480,8 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
const auto PLASTWINDOW = Desktop::focusState()->window();
if (!PLASTWINDOW || !PLASTWINDOW->aliveAndVisible()) {
- tryMoveFocusToMonitor(g_pCompositor->getMonitorInDirection(dir));
+ if (*PMONITORFALLBACK)
+ tryMoveFocusToMonitor(g_pCompositor->getMonitorInDirection(dir));
return {};
}
@@ -1509,7 +1511,7 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
Log::logger->log(Log::DEBUG, "No window found in direction {}, looking for a monitor", Math::toString(dir));
- if (tryMoveFocusToMonitor(g_pCompositor->getMonitorInDirection(dir)))
+ if (*PMONITORFALLBACK && tryMoveFocusToMonitor(g_pCompositor->getMonitorInDirection(dir)))
return {};
static auto PNOFALLBACK = CConfigValue<Hyprlang::INT>("general:no_focus_fallback");