diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 999ef929..bda32d84 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -173,9 +173,6 @@ void CMonitor::onDisconnect() { } } - if (g_pCompositor->m_pLastMonitor == this) - g_pCompositor->setActiveMonitor(BACKUPMON); - // remove mirror if (pMirrorOf) { pMirrorOf->mirrors.erase(std::find_if(pMirrorOf->mirrors.begin(), pMirrorOf->mirrors.end(), [&](const auto& other) { return other == this; })); @@ -239,6 +236,9 @@ void CMonitor::onDisconnect() { g_pEventManager->postEvent(SHyprIPCEvent{"monitorremoved", szName}); + if (g_pCompositor->m_pLastMonitor == this) + g_pCompositor->setActiveMonitor(BACKUPMON); + std::erase_if(g_pCompositor->m_vMonitors, [&](std::shared_ptr& el) { return el.get() == this; }); }