summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
author0xFMD <30713087+0xFMD@users.noreply.github.com>2025-08-31 19:14:39 +0300
committerGitHub <noreply@github.com>2025-08-31 18:14:39 +0200
commit5bb8adbc3228901d199e8d22d6f712bd1d7d4e15 (patch)
tree4bc61196518c37c7845380a723b757b9bf602449 /src/managers
parentea42041f936d5810c5cfa45d6bece12dde2fd9b6 (diff)
dispatchers: allow window address in swapwindow (#11518)
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/KeybindManager.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 0eab9689..536f85b1 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -1608,15 +1608,9 @@ SDispatchResult CKeybindManager::focusCurrentOrLast(std::string args) {
}
SDispatchResult CKeybindManager::swapActive(std::string args) {
- char arg = args[0];
-
- if (!isDirection(args)) {
- Debug::log(ERR, "Cannot move window in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg);
- return {.success = false, .error = std::format("Cannot move window in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)};
- }
-
- Debug::log(LOG, "Swapping active window in direction {}", arg);
- const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
+ char arg = args[0];
+ const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
+ PHLWINDOW PWINDOWTOCHANGETO = nullptr;
if (!PLASTWINDOW)
return {.success = false, .error = "Window to swap with not found"};
@@ -1624,14 +1618,21 @@ SDispatchResult CKeybindManager::swapActive(std::string args) {
if (PLASTWINDOW->isFullscreen())
return {.success = false, .error = "Can't swap fullscreen window"};
- const auto PWINDOWTOCHANGETO = g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
- if (!PWINDOWTOCHANGETO)
- return {.success = false, .error = "Window to swap with not found"};
+ if (isDirection(args))
+ PWINDOWTOCHANGETO = g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
+ else
+ PWINDOWTOCHANGETO = g_pCompositor->getWindowByRegex(args);
+
+ if (!PWINDOWTOCHANGETO || PWINDOWTOCHANGETO == PLASTWINDOW) {
+ Debug::log(ERR, "Can't swap with {}, invalid window", args);
+ return {.success = false, .error = std::format("Can't swap with {}, invalid window", args)};
+ }
+
+ Debug::log(LOG, "Swapping active window with {}", args);
updateRelativeCursorCoords();
g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, PWINDOWTOCHANGETO);
PLASTWINDOW->warpCursor();
-
return {};
}