diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-05-05 12:50:25 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-05-05 12:50:25 +0200 |
| commit | 8bb908a8da3be119cc64552d4fe8a23cdfb938b8 (patch) | |
| tree | 9126a09a72bdcce560405a8f79315ec703021b55 /src/managers/KeybindManager.cpp | |
| parent | c7fd3d46fde472c2e6c2801c9aa7e9376656e235 (diff) | |
Added focusmonitor
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 7e7b4079..0f4d538a 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -15,6 +15,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["togglegroup"] = toggleGroup; m_mDispatchers["changegroupactive"] = changeGroupActive; m_mDispatchers["splitratio"] = alterSplitRatio; + m_mDispatchers["focusmonitor"] = focusMonitor; } void CKeybindManager::addKeybind(SKeybind kb) { @@ -328,7 +329,7 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) { void CKeybindManager::moveFocusTo(std::string args) { char arg = args[0]; - if (arg != 'l' && arg != 'r' && arg != 'u' && arg != 'd' && arg != 't' && arg != 'b') { + if (!isDirection(args)) { Debug::log(ERR, "Cannot move focus in direction %c, unsupported direction. Supported: l,r,u/t,d/b", arg); return; } @@ -366,7 +367,7 @@ void CKeybindManager::moveFocusTo(std::string args) { void CKeybindManager::moveActiveTo(std::string args) { char arg = args[0]; - if (arg != 'l' && arg != 'r' && arg != 'u' && arg != 'd' && arg != 't' && arg != 'b') { + if (!isDirection(args)) { Debug::log(ERR, "Cannot move window in direction %c, unsupported direction. Supported: l,r,u/t,d/b", arg); return; } @@ -415,4 +416,41 @@ void CKeybindManager::alterSplitRatio(std::string args) { return; g_pLayoutManager->getCurrentLayout()->alterSplitRatioBy(PLASTWINDOW, splitratio); +} + +void CKeybindManager::focusMonitor(std::string arg) { + if (isNumber(arg)) { + // change by ID + int monID = -1; + try { + monID = std::stoi(arg); + } catch (std::exception& e) { + // shouldn't happen but jic + Debug::log(ERR, "Error in focusMonitor: invalid num"); + } + + if (monID > -1 && monID < (int)g_pCompositor->m_lMonitors.size()) { + changeworkspace(std::to_string(g_pCompositor->getMonitorFromID(monID)->activeWorkspace)); + } else { + Debug::log(ERR, "Error in focusMonitor: invalid arg 1"); + } + } else { + + if (isDirection(arg)) { + const auto PMONITOR = g_pCompositor->getMonitorInDirection(arg[0]); + if (PMONITOR) { + changeworkspace(std::to_string(PMONITOR->activeWorkspace)); + return; + } + } else { + for (auto& m : g_pCompositor->m_lMonitors) { + if (m.szName == arg) { + changeworkspace(std::to_string(m.activeWorkspace)); + return; + } + } + } + + Debug::log(ERR, "Error in focusMonitor: no such monitor"); + } }
\ No newline at end of file |
