From 6ec932d11fcc490f3d3f8c544af8fa1a5c8ef4f7 Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 22:05:35 +1000 Subject: [PATCH] fix bug which allowed a switch to workspace ID -1. This only happened for the workspace_back_and_forth setting, since it was missing a check. --- src/managers/KeybindManager.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 374525a2..ddf65b42 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -493,11 +493,12 @@ void CKeybindManager::changeworkspace(std::string args) { // Workspace_back_and_forth being enabled means that an attempt to switch to // the current workspace will instead switch to the previous. + const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID( + g_pCompositor->m_pLastMonitor->activeWorkspace); static auto *const PBACKANDFORTH = &g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth")->intValue; - if (*PBACKANDFORTH && g_pCompositor->m_pLastMonitor->activeWorkspace == workspaceToChangeTo) { - - const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID( - g_pCompositor->m_pLastMonitor->activeWorkspace); + if (*PBACKANDFORTH + && PCURRENTWORKSPACE->m_iID == workspaceToChangeTo + && PCURRENTWORKSPACE->m_iPrevWorkspaceID != -1) { workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID; isSwitchingToPrevious = true;