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

@ -259,3 +259,21 @@ void KeybindManager::toggleScratchpad(std::string args) {
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);
}

View file

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

View file

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