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));