From 1a5ed0575833f6f83bfbd4ab12b5a9356989c8f6 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 4 Apr 2022 18:14:23 +0200 Subject: [PATCH] Added nextworkspace lastworkspace handlers --- src/KeybindManager.cpp | 18 ++++++++++++++++++ src/KeybindManager.hpp | 2 ++ src/config/ConfigManager.cpp | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/KeybindManager.cpp b/src/KeybindManager.cpp index 1527f3a..0b53adf 100644 --- a/src/KeybindManager.cpp +++ b/src/KeybindManager.cpp @@ -258,4 +258,22 @@ void KeybindManager::toggleScratchpad(std::string args) { const auto NEWTOP = g_pWindowManager->findFirstWindowOnWorkspace(SCRATCHPAD_ID); if (NEWTOP) g_pWindowManager->setFocusedWindow(NEWTOP->getDrawable()); +} + +void KeybindManager::nextWorkspace(std::string args) { + const auto PMONITOR = g_pWindowManager->getMonitorFromCursor(); + + if (!PMONITOR) + return; + + g_pWindowManager->changeWorkspaceByID(g_pWindowManager->activeWorkspaces[PMONITOR->ID] + 1); +} + +void KeybindManager::lastWorkspace(std::string args) { + const auto PMONITOR = g_pWindowManager->getMonitorFromCursor(); + + if (!PMONITOR) + return; + + g_pWindowManager->changeWorkspaceByID(g_pWindowManager->activeWorkspaces[PMONITOR->ID] < 2 ? 1 : g_pWindowManager->activeWorkspaces[PMONITOR->ID] - 1); } \ No newline at end of file diff --git a/src/KeybindManager.hpp b/src/KeybindManager.hpp index 3b776d3..00a346d 100644 --- a/src/KeybindManager.hpp +++ b/src/KeybindManager.hpp @@ -30,4 +30,6 @@ namespace KeybindManager { void changeSplitRatio(std::string args); void togglePseudoActive(std::string args); void toggleScratchpad(std::string args); + void nextWorkspace(std::string args); + void lastWorkspace(std::string args); }; diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 22148c1..cb1302b 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -128,6 +128,8 @@ void handleBind(const std::string& command, const std::string& value) { if (HANDLER == "splitratio") dispatcher = KeybindManager::changeSplitRatio; if (HANDLER == "pseudo") dispatcher = KeybindManager::togglePseudoActive; if (HANDLER == "scratchpad") dispatcher = KeybindManager::toggleScratchpad; + if (HANDLER == "nextworkspace") dispatcher = KeybindManager::nextWorkspace; + if (HANDLER == "lastworkspace") dispatcher = KeybindManager::lastWorkspace; if (dispatcher && KEY != 0) KeybindManager::keybinds.push_back(Keybind(KeybindManager::modToMask(MOD), KEY, COMMAND, dispatcher));