Skip to content

Conversation

@kolayne
Copy link
Contributor

@kolayne kolayne commented Nov 19, 2025

Describe your PR, what does it fix/add?

Fixes a bug that previous workspace does not exist after swiping to a workspace

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

No

Is it ready for merging, or does it need work?

Probably ready for merge. Or needs a test?

@vaxerski
Copy link
Member

Or needs a test?

would be nice, shouldnt be hard.

@kolayne kolayne force-pushed the workspace_swipe_workspace_previous branch 3 times, most recently from 139f404 to 70fc005 Compare November 22, 2025 10:12
@kolayne
Copy link
Contributor Author

kolayne commented Nov 22, 2025

Done

@kolayne
Copy link
Contributor Author

kolayne commented Nov 24, 2025

On the topic of saving previous workspace: why does CKeybindManager::moveActiveToWorkspace only save previous workspace (lines 1438-1439) if binds:allow_workspaces_cycles is enabled? What does it have to do with cycles?

SDispatchResult CKeybindManager::moveActiveToWorkspace(std::string args) {
PHLWINDOW PWINDOW = nullptr;
if (args.contains(',')) {
PWINDOW = g_pCompositor->getWindowByRegex(args.substr(args.find_last_of(',') + 1));
args = args.substr(0, args.find_last_of(','));
} else {
PWINDOW = g_pCompositor->m_lastWindow.lock();
}
if (!PWINDOW)
return {.success = false, .error = "Window not found"};
const auto& [WORKSPACEID, workspaceName, isAutoID] = getWorkspaceIDNameFromString(args);
if (WORKSPACEID == WORKSPACE_INVALID) {
Debug::log(LOG, "Invalid workspace in moveActiveToWorkspace");
return {.success = false, .error = "Invalid workspace in moveActiveToWorkspace"};
}
if (WORKSPACEID == PWINDOW->workspaceID()) {
Debug::log(LOG, "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);
PHLMONITOR pMonitor = nullptr;
const auto POLDWS = PWINDOW->m_workspace;
static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles");
updateRelativeCursorCoords();
g_pHyprRenderer->damageWindow(PWINDOW);
if (pWorkspace) {
const auto FULLSCREENMODE = PWINDOW->m_fullscreenState.internal;
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
pMonitor = pWorkspace->m_monitor.lock();
g_pCompositor->setActiveMonitor(pMonitor);
g_pCompositor->setWindowFullscreenInternal(PWINDOW, FULLSCREENMODE);
} else {
pWorkspace = g_pCompositor->createNewWorkspace(WORKSPACEID, PWINDOW->monitorID(), workspaceName, false);
pMonitor = pWorkspace->m_monitor.lock();
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
}
POLDWS->m_lastFocusedWindow = POLDWS->getFirstWindow();
if (pWorkspace->m_isSpecialWorkspace)
pMonitor->setSpecialWorkspace(pWorkspace);
else if (POLDWS->m_isSpecialWorkspace)
POLDWS->m_monitor.lock()->setSpecialWorkspace(nullptr);
if (*PALLOWWORKSPACECYCLES)
pWorkspace->rememberPrevWorkspace(POLDWS);
pMonitor->changeWorkspace(pWorkspace);
g_pCompositor->focusWindow(PWINDOW);
PWINDOW->warpCursor();
return {};
}

@vaxerski
Copy link
Member

good question. No clue. Didn't write that

@vaxerski
Copy link
Member

Previous workspace remembering could use a rewrite anyways.

@kolayne
Copy link
Contributor Author

kolayne commented Nov 27, 2025

I also just noticed that, e.g., if I have workspaces 1, 2, and 3 and I swipe-switch from 1 to 3 (with a single gesture), during the gesture we first switch to 2, so 3 considers its previous workspace to be 2 (even though I actually came from workspace 1). IMO it would feel more natural if the workspace only switched at the end of the gesture. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants