diff options
| author | vaxerski <vaxry@vaxry.net> | 2025-01-02 17:36:02 +0100 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2025-01-02 17:36:02 +0100 |
| commit | 365caa49ff4e4f87da687adfa237b8f855aee42b (patch) | |
| tree | 4be7c84b72c02f9e3b4dbe4949a88047505160a1 /src/managers/KeybindManager.cpp | |
| parent | 94381e59991824ab9a5a9cb5fe701181fbcbc81d (diff) | |
keybinds: attempt to wrap around if fallback is allowed in movefocus
fixes #8909
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 9e207fbe..d368d14c 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1423,11 +1423,44 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) { if (*PNOFALLBACK) return {.success = false, .error = std::format("Nothing to focus to in direction {}", arg)}; - Debug::log(LOG, "No monitor found in direction {}, falling back to next window on current workspace", arg); + Debug::log(LOG, "No monitor found in direction {}, getting the inverse edge", arg); - const auto PWINDOWNEXT = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW, true); - if (PWINDOWNEXT) - switchToWindow(PWINDOWNEXT); + const auto PMONITOR = PLASTWINDOW->m_pMonitor.lock(); + + if (!PMONITOR) + return {.success = false, .error = "last window has no monitor?"}; + + if (arg == 'l' || arg == 'r') { + if (STICKS(PLASTWINDOW->m_vPosition.x, PMONITOR->vecPosition.x) && STICKS(PLASTWINDOW->m_vSize.x, PMONITOR->vecSize.x)) + return {.success = false, .error = "move does not make sense, would return back"}; + } else if (STICKS(PLASTWINDOW->m_vPosition.y, PMONITOR->vecPosition.y) && STICKS(PLASTWINDOW->m_vSize.y, PMONITOR->vecSize.y)) + return {.success = false, .error = "move does not make sense, would return back"}; + + CBox box = PMONITOR->logicalBox(); + switch (arg) { + case 'l': + box.x += box.w; + box.w = 1; + break; + case 'r': + box.x -= 1; + box.w = 1; + break; + case 'u': + case 't': + box.y += box.h; + box.h = 1; + break; + case 'd': + case 'b': + box.y -= 1; + box.h = 1; + break; + } + + const auto PWINDOWCANDIDATE = g_pCompositor->getWindowInDirection(box, PMONITOR->activeWorkspace, arg, PLASTWINDOW, PLASTWINDOW->m_bIsFloating); + if (PWINDOWCANDIDATE) + switchToWindow(PWINDOWCANDIDATE); return {}; } |
