From f9e30e985c03ee6cb0641cdd032f003e02976b96 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 17:25:07 +0200 Subject: fix refocus on no window --- src/managers/input/InputManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index f8899f62..9a0d5226 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -182,9 +182,14 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { if (!(pFoundWindow && pFoundWindow->m_bIsFloating && pFoundWindow->m_bCreatedOverFullscreen)) pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); } - } else + } else { pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); + if (refocus && !pFoundWindow) { + pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace); + } + } + if (pFoundWindow) { if (!pFoundWindow->m_bIsX11) { foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); -- cgit v1.2.3 From 81b27be6bb9fa86dae9fdae43e093743d7f24cf7 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 17:29:16 +0200 Subject: reset lastwindow on full LS focus --- src/managers/input/InputManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 9a0d5226..a0016dba 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -272,8 +272,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { g_pCompositor->focusWindow(pFoundWindow, foundSurface); } } else { - if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive && *PFOLLOWMOUSE != 3 && allowKeyboardRefocus) + if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive && *PFOLLOWMOUSE != 3 && allowKeyboardRefocus) { g_pCompositor->focusSurface(foundSurface); + g_pCompositor->m_pLastWindow = nullptr; // reset last window as we have a full focus on a LS + } } wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); -- cgit v1.2.3 From 504d07a87dd439767b5a87cd93b43fac47ca3f79 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 17:36:01 +0200 Subject: fix swipe on workspace style fade --- src/managers/input/Swipe.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/managers') diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp index ca4c60e6..807d0bcc 100644 --- a/src/managers/input/Swipe.cpp +++ b/src/managers/input/Swipe.cpp @@ -143,11 +143,13 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDLeft); PWORKSPACE->m_bForceRendering = true; + PWORKSPACE->m_fAlpha.setValueAndWarp(255.f); if (workspaceIDLeft != workspaceIDRight) { const auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); PWORKSPACER->m_bForceRendering = false; + PWORKSPACE->m_fAlpha.setValueAndWarp(0.f); } PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x - m_sActiveSwipe.pMonitor->vecSize.x, 0)); @@ -163,11 +165,13 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDRight); PWORKSPACE->m_bForceRendering = true; + PWORKSPACE->m_fAlpha.setValueAndWarp(255.f); if (workspaceIDLeft != workspaceIDRight) { const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft); PWORKSPACEL->m_bForceRendering = false; + PWORKSPACE->m_fAlpha.setValueAndWarp(0.f); } PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x + m_sActiveSwipe.pMonitor->vecSize.x, 0)); -- cgit v1.2.3 From 946222f4a7f1cb4a5fb4e28613025ad652982812 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 17:42:10 +0200 Subject: fix typo in swipe alpha control --- src/managers/input/Swipe.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp index 807d0bcc..51be5248 100644 --- a/src/managers/input/Swipe.cpp +++ b/src/managers/input/Swipe.cpp @@ -149,7 +149,7 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) { const auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); PWORKSPACER->m_bForceRendering = false; - PWORKSPACE->m_fAlpha.setValueAndWarp(0.f); + PWORKSPACER->m_fAlpha.setValueAndWarp(0.f); } PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x - m_sActiveSwipe.pMonitor->vecSize.x, 0)); @@ -171,7 +171,7 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) { const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft); PWORKSPACEL->m_bForceRendering = false; - PWORKSPACE->m_fAlpha.setValueAndWarp(0.f); + PWORKSPACEL->m_fAlpha.setValueAndWarp(0.f); } PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x + m_sActiveSwipe.pMonitor->vecSize.x, 0)); -- cgit v1.2.3 From 69d17bf4240e41f2b26abd7a46dfd0e754e9ee9e Mon Sep 17 00:00:00 2001 From: FlafyDev Date: Fri, 19 Aug 2022 21:01:51 +0300 Subject: add input:kb_file --- src/managers/input/InputManager.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index f8899f62..82889f8a 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -519,6 +519,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { const auto NUMLOCKON = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "numlock_by_default") : g_pConfigManager->getInt("input:numlock_by_default"); + const auto FILEPATH = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_file") : g_pConfigManager->getString("input:kb_file"); const auto RULES = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_rules") : g_pConfigManager->getString("input:kb_rules"); const auto MODEL = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_model") : g_pConfigManager->getString("input:kb_model"); const auto LAYOUT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_layout") : g_pConfigManager->getString("input:kb_layout"); @@ -526,7 +527,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_options") : g_pConfigManager->getString("input:kb_options"); try { - if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options) { + if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options && FILEPATH == pKeyboard->xkbFilePath) { Debug::log(LOG, "Not applying config to keyboard, it did not change."); return; } @@ -540,6 +541,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { pKeyboard->repeatDelay = REPEATDELAY; pKeyboard->repeatRate = REPEATRATE; pKeyboard->numlockOn = NUMLOCKON; + pKeyboard->xkbFilePath = FILEPATH.c_str(); xkb_rule_names rules = { .rules = RULES.c_str(), @@ -563,7 +565,21 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { Debug::log(LOG, "Attempting to create a keymap for layout %s with variant %s (rules: %s, model: %s, options: %s)", rules.layout, rules.variant, rules.rules, rules.model, rules.options); - auto KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); + xkb_keymap * KEYMAP = NULL; + + if (!FILEPATH.empty()) { + auto path = g_pConfigManager->absolutePath(FILEPATH); + + if (!std::filesystem::exists(path)) { + Debug::log(ERR, "input:kb_file= file doesnt exist"); + } else { + KEYMAP = xkb_keymap_new_from_file(CONTEXT, fopen(path.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); + } + } + + if (!KEYMAP) { + KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); + } if (!KEYMAP) { g_pConfigManager->addParseError("Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS + ", layout: " + LAYOUT + " )"); @@ -942,4 +958,4 @@ void CInputManager::disableAllKeyboards(bool virt) { k.active = false; } -} \ No newline at end of file +} -- cgit v1.2.3 From f0ad77251b28fcf48dcaf25f23e3a140d69a4735 Mon Sep 17 00:00:00 2001 From: FlafyDev Date: Fri, 19 Aug 2022 23:18:09 +0300 Subject: move absolutePath to MiscFunctions --- src/managers/input/InputManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 82889f8a..b35d9064 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -568,7 +568,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { xkb_keymap * KEYMAP = NULL; if (!FILEPATH.empty()) { - auto path = g_pConfigManager->absolutePath(FILEPATH); + auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath); if (!std::filesystem::exists(path)) { Debug::log(ERR, "input:kb_file= file doesnt exist"); -- cgit v1.2.3 From 1b1a0259a856892c136d03fe210151b0cdeda91c Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 23:22:53 +0200 Subject: fix crash --- src/managers/input/InputManager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index d6cf00be..87869da1 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -185,9 +185,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { } else { pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); - if (refocus && !pFoundWindow) { - pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace); - } + // TODO: this causes crashes, sometimes. ??? + // if (refocus && !pFoundWindow) { + // pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace); + // } } if (pFoundWindow) { -- cgit v1.2.3 From 04f0efadc33fd3ac9fb0ed176dbc00dde9906f8e Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 20:21:21 +1000 Subject: add switching to previous workspace --- src/managers/KeybindManager.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 9939993a..543066c1 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -454,11 +454,31 @@ void CKeybindManager::changeworkspace(std::string args) { int workspaceToChangeTo = 0; std::string workspaceName = ""; + // Flag needed so that the previous workspace is not recorded when switching + // to a previous workspace. + bool isSwitchingToPrevious = false; + if (args.find("[internal]") == 0) { workspaceToChangeTo = std::stoi(args.substr(10)); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToChangeTo); 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); + + // Do nothing if there's no previous workspace, otherwise switch to it. + if (P_CURRENT_WORKSPACE->m_iPrevWorkspaceID == -1) { + Debug::log(LOG, "No previous workspace to change to"); + return; + } + else { + workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; + isSwitchingToPrevious = true; + + // TODO: Add support for cycles + P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + } } else { workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName); } @@ -477,6 +497,10 @@ void CKeybindManager::changeworkspace(std::string args) { const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(workspaceToChangeTo); + if (!isSwitchingToPrevious) + // Remember previous workspace. + PWORKSPACETOCHANGETO->m_iPrevWorkspaceID = g_pCompositor->getMonitorFromCursor()->activeWorkspace; + if (workspaceToChangeTo == SPECIAL_WORKSPACE_ID) PWORKSPACETOCHANGETO->m_iMonitorID = PMONITOR->ID; @@ -541,6 +565,10 @@ void CKeybindManager::changeworkspace(std::string args) { const auto PWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique(PMONITOR->ID, workspaceName, workspaceToChangeTo == SPECIAL_WORKSPACE_ID)).get(); + if (!isSwitchingToPrevious) + // Remember previous workspace. + PWORKSPACE->m_iPrevWorkspaceID = OLDWORKSPACE; + // start anim on new workspace PWORKSPACE->startAnim(true, ANIMTOLEFT); -- cgit v1.2.3 From d6ff7e40cfde6a8484b50911358032b4c53c721c Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 20:40:06 +1000 Subject: add general:workspace_back_and_forth option --- src/managers/KeybindManager.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/managers') 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(); -- cgit v1.2.3 From 9ee42836d5e2c707f7cf203628a0ae530d59c5cd Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 20:47:56 +1000 Subject: add general:allow_workspace_cycles option --- src/managers/KeybindManager.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 45af02a0..ab22d98f 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -476,8 +476,10 @@ void CKeybindManager::changeworkspace(std::string args) { workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; isSwitchingToPrevious = true; - // TODO: Add support for cycles - P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + // If the previous workspace ID isn't reset, cycles can form when continually going + // to the previous workspace again and again. + if (!g_pConfigManager->getConfigValuePtr("general:allow_workspace_cycles")->intValue) + P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; } } else { workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName); @@ -499,8 +501,10 @@ void CKeybindManager::changeworkspace(std::string args) { workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; isSwitchingToPrevious = true; - // TODO: Add support for cycles - P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + // If the previous workspace ID isn't reset, cycles can form when continually going + // to the previous workspace again and again. + if (!g_pConfigManager->getConfigValuePtr("general:allow_workspace_cycles")->intValue) + P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; } // remove constraints -- cgit v1.2.3 From 3c8c605541d6b3e046951ba8710dfb2e9452a3de Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 21:58:46 +1000 Subject: fix style conflicts and config + monitor retrieval --- src/managers/KeybindManager.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index ab22d98f..374525a2 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -464,22 +464,23 @@ void CKeybindManager::changeworkspace(std::string args) { if (PWORKSPACE) workspaceName = PWORKSPACE->m_szName; } else if (args.find("previous") == 0) { - const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID( + const auto PCURRENTWORKSPACE = 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) { + if (PCURRENTWORKSPACE->m_iPrevWorkspaceID == -1) { Debug::log(LOG, "No previous workspace to change to"); return; } else { - workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; + workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID; isSwitchingToPrevious = true; // If the previous workspace ID isn't reset, cycles can form when continually going // to the previous workspace again and again. - if (!g_pConfigManager->getConfigValuePtr("general:allow_workspace_cycles")->intValue) - P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + static auto *const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue; + if (!*PALLOWWORKSPACECYCLES) + PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1; } } else { workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName); @@ -492,19 +493,20 @@ 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. - if (g_pConfigManager->getConfigValuePtr("general:workspace_back_and_forth")->intValue == 1 - && g_pCompositor->getMonitorFromCursor()->activeWorkspace == workspaceToChangeTo) { + static auto *const PBACKANDFORTH = &g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth")->intValue; + if (*PBACKANDFORTH && g_pCompositor->m_pLastMonitor->activeWorkspace == workspaceToChangeTo) { - const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID( - g_pCompositor->getMonitorFromCursor()->activeWorkspace); + const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID( + g_pCompositor->m_pLastMonitor->activeWorkspace); - workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; + workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID; isSwitchingToPrevious = true; // If the previous workspace ID isn't reset, cycles can form when continually going // to the previous workspace again and again. - if (!g_pConfigManager->getConfigValuePtr("general:allow_workspace_cycles")->intValue) - P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + static auto *const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue; + if (!*PALLOWWORKSPACECYCLES) + PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1; } // remove constraints @@ -518,7 +520,7 @@ void CKeybindManager::changeworkspace(std::string args) { if (!isSwitchingToPrevious) // Remember previous workspace. - PWORKSPACETOCHANGETO->m_iPrevWorkspaceID = g_pCompositor->getMonitorFromCursor()->activeWorkspace; + PWORKSPACETOCHANGETO->m_iPrevWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace; if (workspaceToChangeTo == SPECIAL_WORKSPACE_ID) PWORKSPACETOCHANGETO->m_iMonitorID = PMONITOR->ID; -- cgit v1.2.3 From 6ec932d11fcc490f3d3f8c544af8fa1a5c8ef4f7 Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 22:05:35 +1000 Subject: 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(-) (limited to 'src/managers') 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; -- cgit v1.2.3 From 9dbdd66da417eb2316387f3af078349c50bc2929 Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 22:11:40 +1000 Subject: fix retrieval of monitor --- src/managers/KeybindManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index ddf65b42..3d821d14 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -465,7 +465,7 @@ void CKeybindManager::changeworkspace(std::string args) { workspaceName = PWORKSPACE->m_szName; } else if (args.find("previous") == 0) { const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID( - g_pCompositor->getMonitorFromCursor()->activeWorkspace); + g_pCompositor->m_pLastMonitor->activeWorkspace); // Do nothing if there's no previous workspace, otherwise switch to it. if (PCURRENTWORKSPACE->m_iPrevWorkspaceID == -1) { -- cgit v1.2.3