core: fix workspace persistence tracking (#11239)
This commit is contained in:
parent
5d4b4ecbfb
commit
c63d0003a1
7 changed files with 140 additions and 10 deletions
|
|
@ -3109,6 +3109,8 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspace
|
|||
if (!m_lastMonitor)
|
||||
return;
|
||||
|
||||
std::vector<PHLWORKSPACE> persistentFound;
|
||||
|
||||
for (const auto& rule : rules) {
|
||||
if (!rule.isPersistent)
|
||||
continue;
|
||||
|
|
@ -3142,17 +3144,20 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspace
|
|||
}
|
||||
PWORKSPACE = getWorkspaceByID(id);
|
||||
if (!PWORKSPACE)
|
||||
createNewWorkspace(id, PMONITOR ? PMONITOR->m_id : m_lastMonitor->m_id, wsname, false);
|
||||
PWORKSPACE = createNewWorkspace(id, PMONITOR ? PMONITOR->m_id : m_lastMonitor->m_id, wsname, false);
|
||||
}
|
||||
|
||||
if (PWORKSPACE)
|
||||
PWORKSPACE->m_persistent = true;
|
||||
|
||||
if (!PMONITOR) {
|
||||
Debug::log(ERR, "ensurePersistentWorkspacesPresent: couldn't resolve monitor for {}, skipping", rule.monitor);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (PWORKSPACE)
|
||||
PWORKSPACE->setPersistent(true);
|
||||
|
||||
if (!pWorkspace)
|
||||
persistentFound.emplace_back(PWORKSPACE);
|
||||
|
||||
if (PWORKSPACE) {
|
||||
if (PWORKSPACE->m_monitor == PMONITOR) {
|
||||
Debug::log(LOG, "ensurePersistentWorkspacesPresent: workspace persistent {} already on {}", rule.workspaceString, PMONITOR->m_name);
|
||||
|
|
@ -3165,4 +3170,22 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspace
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pWorkspace) {
|
||||
// check non-persistent and downgrade if workspace is no longer persistent
|
||||
std::vector<PHLWORKSPACEREF> toDowngrade;
|
||||
for (auto& w : getWorkspaces()) {
|
||||
if (!w->isPersistent())
|
||||
continue;
|
||||
|
||||
if (std::ranges::contains(persistentFound, w.lock()))
|
||||
continue;
|
||||
|
||||
toDowngrade.emplace_back(w);
|
||||
}
|
||||
|
||||
for (auto& ws : toDowngrade) {
|
||||
ws->setPersistent(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue