diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index ff1791f5..53c008f9 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -34,6 +34,7 @@ void CConfigManager::setDefaultVars() { configValues["general:apply_sens_to_raw"].intValue = 0; configValues["general:main_mod"].strValue = "SUPER"; // exposed to the user for easier configuring configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask("SUPER"); // actually used and automatically calculated + configValues["general:workspace_back_and_forth"].intValue = 0; configValues["general:damage_tracking"].strValue = "full"; configValues["general:damage_tracking_internal"].intValue = DAMAGE_TRACKING_FULL; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 543066c1..45af02a0 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -464,8 +464,8 @@ void CKeybindManager::changeworkspace(std::string args) { if (PWORKSPACE) workspaceName = PWORKSPACE->m_szName; } else if (args.find("previous") == 0) { - const auto P_MONITOR = g_pCompositor->getMonitorFromCursor(); - const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID(P_MONITOR->activeWorkspace); + const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID( + g_pCompositor->getMonitorFromCursor()->activeWorkspace); // Do nothing if there's no previous workspace, otherwise switch to it. if (P_CURRENT_WORKSPACE->m_iPrevWorkspaceID == -1) { @@ -488,6 +488,21 @@ void CKeybindManager::changeworkspace(std::string args) { return; } + // Workspace_back_and_forth being enabled means that an attempt to switch to + // the current workspace will instead switch to the previous. + if (g_pConfigManager->getConfigValuePtr("general:workspace_back_and_forth")->intValue == 1 + && g_pCompositor->getMonitorFromCursor()->activeWorkspace == workspaceToChangeTo) { + + const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID( + g_pCompositor->getMonitorFromCursor()->activeWorkspace); + + workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; + isSwitchingToPrevious = true; + + // TODO: Add support for cycles + P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + } + // remove constraints g_pInputManager->unconstrainMouse();