diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-03-13 15:19:25 +0000 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-03-13 15:19:25 +0000 |
| commit | e749af7b60386f4ff414ef3e2e804523046e46a9 (patch) | |
| tree | db7999bda973306d2fb7f5159b3499cbe4c0f3b8 /src/managers/KeybindManager.cpp | |
| parent | 17deeb07ad4ce1b34bfe22524f9b248c5c6e01e6 (diff) | |
dispatchers: remember named workspaces in prev
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 95144a61..9d652932 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -708,22 +708,22 @@ void CKeybindManager::changeworkspace(std::string args) { const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); // Do nothing if there's no previous workspace, otherwise switch to it. - if (PCURRENTWORKSPACE->m_iPrevWorkspaceID == -1) { + if (PCURRENTWORKSPACE->m_sPrevWorkspace.iID == -1) { Debug::log(LOG, "No previous workspace to change to"); return; } else { - workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID; + workspaceToChangeTo = PCURRENTWORKSPACE->m_sPrevWorkspace.iID; if (const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(workspaceToChangeTo); PWORKSPACETOCHANGETO) workspaceName = PWORKSPACETOCHANGETO->m_szName; else - workspaceName = std::to_string(workspaceToChangeTo); + workspaceName = PCURRENTWORKSPACE->m_sPrevWorkspace.name.empty() ? std::to_string(workspaceToChangeTo) : PCURRENTWORKSPACE->m_sPrevWorkspace.name; // If the previous workspace ID isn't reset, cycles can form when continually going // to the previous workspace again and again. static auto* const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue; if (!*PALLOWWORKSPACECYCLES) - PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1; + PCURRENTWORKSPACE->m_sPrevWorkspace = {-1, ""}; else isSwitchingToPrevious = true; } @@ -741,22 +741,22 @@ void CKeybindManager::changeworkspace(std::string args) { 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 && PCURRENTWORKSPACE && PCURRENTWORKSPACE->m_iID == workspaceToChangeTo && PCURRENTWORKSPACE->m_iPrevWorkspaceID != -1 && !internal) { + if (*PBACKANDFORTH && PCURRENTWORKSPACE && PCURRENTWORKSPACE->m_iID == workspaceToChangeTo && PCURRENTWORKSPACE->m_sPrevWorkspace.iID != -1 && !internal) { - const auto PPREVWORKSPACE = g_pCompositor->getWorkspaceByID(PCURRENTWORKSPACE->m_iPrevWorkspaceID); + const auto PPREVWORKSPACE = g_pCompositor->getWorkspaceByID(PCURRENTWORKSPACE->m_sPrevWorkspace.iID); - workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID; + workspaceToChangeTo = PCURRENTWORKSPACE->m_sPrevWorkspace.iID; if (PPREVWORKSPACE) workspaceName = PPREVWORKSPACE->m_szName; else - workspaceName = std::to_string(workspaceToChangeTo); + workspaceName = PCURRENTWORKSPACE->m_sPrevWorkspace.name.empty() ? std::to_string(workspaceToChangeTo) : PCURRENTWORKSPACE->m_sPrevWorkspace.name; // If the previous workspace ID isn't reset, cycles can form when continually going // to the previous workspace again and again. static auto* const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue; if (!*PALLOWWORKSPACECYCLES) - PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1; + PCURRENTWORKSPACE->m_sPrevWorkspace = {-1, ""}; else isSwitchingToPrevious = true; @@ -778,9 +778,11 @@ void CKeybindManager::changeworkspace(std::string args) { const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(workspaceToChangeTo); - if (!isSwitchingToPrevious && !internal) + if (!isSwitchingToPrevious && !internal) { // Remember previous workspace. - PWORKSPACETOCHANGETO->m_iPrevWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace; + PWORKSPACETOCHANGETO->m_sPrevWorkspace.iID = g_pCompositor->m_pLastMonitor->activeWorkspace; + PWORKSPACETOCHANGETO->m_sPrevWorkspace.name = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace)->m_szName; + } if (g_pCompositor->isWorkspaceSpecial(workspaceToChangeTo)) PWORKSPACETOCHANGETO->m_iMonitorID = PMONITOR->ID; @@ -874,9 +876,12 @@ void CKeybindManager::changeworkspace(std::string args) { const bool ANOTHERMONITOR = PMONITOR != g_pCompositor->m_pLastMonitor; - if (!isSwitchingToPrevious) + if (!isSwitchingToPrevious) { // Remember previous workspace. - PWORKSPACE->m_iPrevWorkspaceID = OLDWORKSPACE; + PWORKSPACE->m_sPrevWorkspace.iID = OLDWORKSPACE; + if (const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(OLDWORKSPACE); POLDWORKSPACE) + PWORKSPACE->m_sPrevWorkspace.name = POLDWORKSPACE->m_szName; + } // start anim on new workspace PWORKSPACE->startAnim(true, ANIMTOLEFT); |
