summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-04-05 19:32:05 +0100
committerVaxry <vaxry@vaxry.net>2024-04-05 19:43:51 +0100
commit094bce811831675b03939e4a2d527998850c906d (patch)
tree56bcdb22e52547f07418c0cff11ad15af998e635 /src
parent4909b0f350f9d3b07a95c62e3ed51981f332b98f (diff)
core: simplify sanityCheckWorkspaces
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp37
-rw-r--r--src/desktop/Workspace.cpp3
-rw-r--r--src/desktop/Workspace.hpp2
3 files changed, 8 insertions, 34 deletions
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;
}
}
diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp
index 80da2749..7146e13d 100644
--- a/src/desktop/Workspace.cpp
+++ b/src/desktop/Workspace.cpp
@@ -41,6 +41,9 @@ void CWorkspace::init(PHLWORKSPACE self) {
m_bInert = false;
+ const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(self);
+ m_bPersistent = WORKSPACERULE.isPersistent;
+
g_pEventManager->postEvent({"createworkspace", m_szName});
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)});
EMIT_HOOK_EVENT("createWorkspace", this);
diff --git a/src/desktop/Workspace.hpp b/src/desktop/Workspace.hpp
index deb108ec..26fe38d9 100644
--- a/src/desktop/Workspace.hpp
+++ b/src/desktop/Workspace.hpp
@@ -61,6 +61,8 @@ class CWorkspace {
// Whether the user configured command for on-created-empty has been executed, if any
bool m_bOnCreatedEmptyExecuted = false;
+ bool m_bPersistent = false;
+
// Inert: destroyed and invalid. If this is true, release the ptr you have.
bool inert();