workspaces: fixup workspaces not activating on workspace switch

This commit is contained in:
vaxerski 2023-04-14 15:28:22 +01:00
parent 3f2a18a435
commit 727160f0a4
2 changed files with 15 additions and 3 deletions

View file

@ -477,9 +477,17 @@ float CMonitor::getDefaultScale() {
}
void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal) {
if (!pWorkspace || pWorkspace->m_iID == activeWorkspace)
if (!pWorkspace)
return;
if (pWorkspace->m_iID == activeWorkspace) {
// in some cases (e.g. workspace from one monitor to another)
// we need to send this
g_pCompositor->deactivateAllWLRWorkspaces(pWorkspace->m_pWlrHandle);
pWorkspace->setActive(true);
return;
}
if (pWorkspace->m_bIsSpecialWorkspace) {
Debug::log(ERR, "BUG THIS: Attempted to changeWorkspace to special!");
return;
@ -509,7 +517,7 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal) {
}
// set some flags and fire event
g_pCompositor->deactivateAllWLRWorkspaces();
g_pCompositor->deactivateAllWLRWorkspaces(pWorkspace->m_pWlrHandle);
pWorkspace->setActive(true);
g_pEventManager->postEvent(SHyprIPCEvent{"workspace", pWorkspace->m_szName});
EMIT_HOOK_EVENT("workspace", pWorkspace);

View file

@ -777,6 +777,8 @@ void CKeybindManager::changeworkspace(std::string args) {
if (!PMONITORWORKSPACEOWNER)
return;
g_pCompositor->setActiveMonitor(PMONITORWORKSPACEOWNER);
const auto PREVWSDATA = pWorkspaceToChangeTo->m_sPrevWorkspace;
PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo);
@ -810,11 +812,12 @@ void CKeybindManager::changeworkspace(std::string args) {
const auto PMONITORWORKSPACEOWNER = PMONITOR->ID == pWorkspaceToChangeTo->m_iMonitorID ? PMONITOR : g_pCompositor->getMonitorFromID(pWorkspaceToChangeTo->m_iMonitorID);
g_pCompositor->setActiveMonitor(PMONITORWORKSPACEOWNER);
PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo);
g_pCompositor->warpCursorTo(PMONITORWORKSPACEOWNER->vecPosition + PMONITORWORKSPACEOWNER->vecSize / 2.f);
if (PMONITOR != PMONITORWORKSPACEOWNER) {
g_pCompositor->setActiveMonitor(PMONITORWORKSPACEOWNER);
if (const auto PLASTWINDOW = pWorkspaceToChangeTo->getLastFocusedWindow(); PLASTWINDOW)
g_pCompositor->focusWindow(PLASTWINDOW);
else
@ -869,6 +872,7 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
if (pWorkspace) {
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
g_pCompositor->setActiveMonitor(PMONITOR);
PMONITOR->changeWorkspace(pWorkspace);
} else {
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);