Added nextworkspace lastworkspace handlers

This commit is contained in:
vaxerski 2022-04-04 18:14:23 +02:00
parent 07b9efb114
commit 1a5ed05758
3 changed files with 22 additions and 0 deletions

View File

@ -258,4 +258,22 @@ void KeybindManager::toggleScratchpad(std::string args) {
const auto NEWTOP = g_pWindowManager->findFirstWindowOnWorkspace(SCRATCHPAD_ID); const auto NEWTOP = g_pWindowManager->findFirstWindowOnWorkspace(SCRATCHPAD_ID);
if (NEWTOP) if (NEWTOP)
g_pWindowManager->setFocusedWindow(NEWTOP->getDrawable()); 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);
} }

View File

@ -30,4 +30,6 @@ namespace KeybindManager {
void changeSplitRatio(std::string args); void changeSplitRatio(std::string args);
void togglePseudoActive(std::string args); void togglePseudoActive(std::string args);
void toggleScratchpad(std::string args); void toggleScratchpad(std::string args);
void nextWorkspace(std::string args);
void lastWorkspace(std::string args);
}; };

View File

@ -128,6 +128,8 @@ void handleBind(const std::string& command, const std::string& value) {
if (HANDLER == "splitratio") dispatcher = KeybindManager::changeSplitRatio; if (HANDLER == "splitratio") dispatcher = KeybindManager::changeSplitRatio;
if (HANDLER == "pseudo") dispatcher = KeybindManager::togglePseudoActive; if (HANDLER == "pseudo") dispatcher = KeybindManager::togglePseudoActive;
if (HANDLER == "scratchpad") dispatcher = KeybindManager::toggleScratchpad; if (HANDLER == "scratchpad") dispatcher = KeybindManager::toggleScratchpad;
if (HANDLER == "nextworkspace") dispatcher = KeybindManager::nextWorkspace;
if (HANDLER == "lastworkspace") dispatcher = KeybindManager::lastWorkspace;
if (dispatcher && KEY != 0) if (dispatcher && KEY != 0)
KeybindManager::keybinds.push_back(Keybind(KeybindManager::modToMask(MOD), KEY, COMMAND, dispatcher)); KeybindManager::keybinds.push_back(Keybind(KeybindManager::modToMask(MOD), KEY, COMMAND, dispatcher));