From 094bce811831675b03939e4a2d527998850c906d Mon Sep 17 00:00:00 2001 From: Vaxry Date: Fri, 5 Apr 2024 19:32:05 +0100 Subject: core: simplify sanityCheckWorkspaces --- src/Compositor.cpp | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) (limited to 'src/Compositor.cpp') diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 5c1092ec..43473c2c 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1256,43 +1256,12 @@ PHLWORKSPACE CCompositor::getWorkspaceByID(const int& id) { void CCompositor::sanityCheckWorkspaces() { auto it = m_vWorkspaces.begin(); while (it != m_vWorkspaces.end()) { - - const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(*it); - if (WORKSPACERULE.isPersistent) { - ++it; + // If ref == 1, only the compositor holds a ref, which means it's inactive and has no mapped windows. + if (!(*it)->m_bPersistent && it->use_count() == 1) { + it = m_vWorkspaces.erase(it); continue; } - const auto& WORKSPACE = *it; - const auto WINDOWSONWORKSPACE = getWindowsOnWorkspace(WORKSPACE->m_iID); - - if (WINDOWSONWORKSPACE == 0) { - if (!isWorkspaceVisible(WORKSPACE)) { - - if (WORKSPACE->m_bIsSpecialWorkspace) { - if (WORKSPACE->m_fAlpha.value() > 0.f /* don't abruptly end the fadeout */) { - ++it; - continue; - } - - const auto PMONITOR = getMonitorFromID(WORKSPACE->m_iMonitorID); - - if (PMONITOR && PMONITOR->activeSpecialWorkspace == WORKSPACE) - PMONITOR->setSpecialWorkspace(nullptr); - } - - it->get()->markInert(); - it = m_vWorkspaces.erase(it); - continue; - } - if (!WORKSPACE->m_bOnCreatedEmptyExecuted) { - if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd) - g_pKeybindManager->spawn(*cmd); - - WORKSPACE->m_bOnCreatedEmptyExecuted = true; - } - } - ++it; } } -- cgit v1.2.3