From 3d5e2c1dc34e1099fd56bad61848f7a48268ea77 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 9 Apr 2022 13:26:55 +0200 Subject: Added movefocus dispatcher --- src/managers/KeybindManager.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/managers/KeybindManager.cpp') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index d820e83e..8cf22892 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -54,6 +54,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t else if (k.handler == "fullscreen") { fullscreenActive(k.arg); } else if (k.handler == "movetoworkspace") { moveActiveToWorkspace(k.arg); } else if (k.handler == "pseudo") { toggleActivePseudo(k.arg); } + else if (k.handler == "movefocus") { moveFocusTo(k.arg); } found = true; } @@ -244,3 +245,22 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) { PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition + g_pCompositor->getMonitorFromID(NEWWORKSPACE->monitorID)->vecPosition; } } + +void CKeybindManager::moveFocusTo(std::string args) { + char arg = args[0]; + + if (arg != 'l' && arg != 'r' && arg != 'u' && arg != 'd' && arg != 't' && arg != 'b') { + Debug::log(ERR, "Cannot move window in direction %c, unsupported direction. Supported: l,r,u/t,d/b", arg); + return; + } + + const auto PLASTWINDOW = g_pCompositor->m_pLastWindow; + + if (!g_pCompositor->windowValidMapped(PLASTWINDOW)) + return; + + const auto PWINDOWTOCHANGETO = g_pCompositor->getWindowInDirection(PLASTWINDOW, arg); + + if (PWINDOWTOCHANGETO) + g_pCompositor->focusWindow(PWINDOWTOCHANGETO); +} \ No newline at end of file -- cgit v1.2.3