Skip to content

Commit

Permalink
core: simplify sanityCheckWorkspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Apr 5, 2024
1 parent 4909b0f commit 094bce8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
37 changes: 3 additions & 34 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

This comment has been minimized.

Copy link
@thejch

thejch Apr 6, 2024

Contributor

bug: this removes the on created command functionality

g_pKeybindManager->spawn(*cmd);

WORKSPACE->m_bOnCreatedEmptyExecuted = true;
}
}

++it;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/desktop/Workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/desktop/Workspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 094bce8

Please sign in to comment.