mirror of
https://github.com/hyprwm/Hyprland
synced 2025-12-20 04:30:12 +01:00
keybinds: fix previous workspace remembering (#12399)
* swipe: Fix previous workspace remembering in workspace gesture Fixes a bug that previous workspace does not exist after swiping to a workspace * tests: Test that `workspace previous` works after workspace gesture * moveActiveToWorkspace: remember previous workspace unconditionally
This commit is contained in:
parent
ebe74be75a
commit
222dbe99d0
3 changed files with 33 additions and 8 deletions
|
|
@ -160,6 +160,33 @@ static bool test() {
|
||||||
// The cursor should have moved because of the gesture
|
// The cursor should have moved because of the gesture
|
||||||
EXPECT(cursorPos1 != cursorPos2, true);
|
EXPECT(cursorPos1 != cursorPos2, true);
|
||||||
|
|
||||||
|
// Test that `workspace previous` works correctly after a workspace gesture.
|
||||||
|
{
|
||||||
|
OK(getFromSocket("/keyword gestures:workspace_swipe_invert 0"));
|
||||||
|
OK(getFromSocket("/keyword gestures:workspace_swipe_create_new 1"));
|
||||||
|
OK(getFromSocket("/dispatch workspace 3"));
|
||||||
|
|
||||||
|
// Come to workspace 5 from workspace 3: 5 will remember that.
|
||||||
|
OK(getFromSocket("/dispatch workspace 5"));
|
||||||
|
Tests::spawnKitty(); // Keep workspace 5 open
|
||||||
|
|
||||||
|
// Swipe from 1 to 5: 5 shall remember that.
|
||||||
|
OK(getFromSocket("/dispatch workspace 1"));
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:alt 1"));
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:gesture right,3"));
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:alt 0"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activeworkspace"), "ID 5 (5)");
|
||||||
|
|
||||||
|
// Must return to 1 rather than 3
|
||||||
|
OK(getFromSocket("/dispatch workspace previous"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activeworkspace"), "ID 1 (1)");
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch workspace previous"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activeworkspace"), "ID 5 (5)");
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch workspace 1"));
|
||||||
|
}
|
||||||
|
|
||||||
// kill all
|
// kill all
|
||||||
NLog::log("{}Killing all windows", Colors::YELLOW);
|
NLog::log("{}Killing all windows", Colors::YELLOW);
|
||||||
Tests::killAllWindows();
|
Tests::killAllWindows();
|
||||||
|
|
|
||||||
|
|
@ -1391,10 +1391,9 @@ SDispatchResult CKeybindManager::moveActiveToWorkspace(std::string args) {
|
||||||
return {.success = false, .error = "Not moving to workspace because it didn't change."};
|
return {.success = false, .error = "Not moving to workspace because it didn't change."};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pWorkspace = g_pCompositor->getWorkspaceByID(WORKSPACEID);
|
auto pWorkspace = g_pCompositor->getWorkspaceByID(WORKSPACEID);
|
||||||
PHLMONITOR pMonitor = nullptr;
|
PHLMONITOR pMonitor = nullptr;
|
||||||
const auto POLDWS = PWINDOW->m_workspace;
|
const auto POLDWS = PWINDOW->m_workspace;
|
||||||
static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles");
|
|
||||||
|
|
||||||
updateRelativeCursorCoords();
|
updateRelativeCursorCoords();
|
||||||
|
|
||||||
|
|
@ -1419,8 +1418,7 @@ SDispatchResult CKeybindManager::moveActiveToWorkspace(std::string args) {
|
||||||
else if (POLDWS->m_isSpecialWorkspace)
|
else if (POLDWS->m_isSpecialWorkspace)
|
||||||
POLDWS->m_monitor.lock()->setSpecialWorkspace(nullptr);
|
POLDWS->m_monitor.lock()->setSpecialWorkspace(nullptr);
|
||||||
|
|
||||||
if (*PALLOWWORKSPACECYCLES)
|
pWorkspace->rememberPrevWorkspace(POLDWS);
|
||||||
pWorkspace->rememberPrevWorkspace(POLDWS);
|
|
||||||
|
|
||||||
pMonitor->changeWorkspace(pWorkspace);
|
pMonitor->changeWorkspace(pWorkspace);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ void CUnifiedWorkspaceSwipeGesture::end() {
|
||||||
|
|
||||||
pSwitchedTo = PWORKSPACER;
|
pSwitchedTo = PWORKSPACER;
|
||||||
}
|
}
|
||||||
m_workspaceBegin->rememberPrevWorkspace(pSwitchedTo);
|
pSwitchedTo->rememberPrevWorkspace(m_workspaceBegin);
|
||||||
|
|
||||||
g_pHyprRenderer->damageMonitor(m_monitor.lock());
|
g_pHyprRenderer->damageMonitor(m_monitor.lock());
|
||||||
|
|
||||||
|
|
@ -311,4 +311,4 @@ void CUnifiedWorkspaceSwipeGesture::end() {
|
||||||
for (auto const& ls : Desktop::focusState()->monitor()->m_layerSurfaceLayers[2]) {
|
for (auto const& ls : Desktop::focusState()->monitor()->m_layerSurfaceLayers[2]) {
|
||||||
*ls->m_alpha = pSwitchedTo->m_hasFullscreenWindow && pSwitchedTo->m_fullscreenMode == FSMODE_FULLSCREEN ? 0.f : 1.f;
|
*ls->m_alpha = pSwitchedTo->m_hasFullscreenWindow && pSwitchedTo->m_fullscreenMode == FSMODE_FULLSCREEN ? 0.f : 1.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue