dispatchers: allow window address in swapwindow (#11518)
This commit is contained in:
parent
ea42041f93
commit
5bb8adbc32
2 changed files with 127 additions and 13 deletions
|
|
@ -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 {};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue