mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 18:25:59 +01:00
monitor: use a scope guard for disconnect events
This commit is contained in:
parent
595eb89f6e
commit
46bf87c8d1
1 changed files with 6 additions and 3 deletions
|
@ -229,6 +229,12 @@ void CMonitor::onConnect(bool noRule) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMonitor::onDisconnect(bool destroy) {
|
void CMonitor::onDisconnect(bool destroy) {
|
||||||
|
CScopeGuard x = {[this]() {
|
||||||
|
if (g_pCompositor->m_bIsShuttingDown)
|
||||||
|
return;
|
||||||
|
g_pEventManager->postEvent(SHyprIPCEvent{"monitorremoved", szName});
|
||||||
|
EMIT_HOOK_EVENT("monitorRemoved", this);
|
||||||
|
}};
|
||||||
|
|
||||||
if (renderTimer) {
|
if (renderTimer) {
|
||||||
wl_event_source_remove(renderTimer);
|
wl_event_source_remove(renderTimer);
|
||||||
|
@ -341,9 +347,6 @@ void CMonitor::onDisconnect(bool destroy) {
|
||||||
g_pHyprRenderer->m_pMostHzMonitor = pMonitorMostHz;
|
g_pHyprRenderer->m_pMostHzMonitor = pMonitorMostHz;
|
||||||
}
|
}
|
||||||
std::erase_if(g_pCompositor->m_vMonitors, [&](SP<CMonitor>& el) { return el.get() == this; });
|
std::erase_if(g_pCompositor->m_vMonitors, [&](SP<CMonitor>& el) { return el.get() == this; });
|
||||||
|
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"monitorremoved", szName});
|
|
||||||
EMIT_HOOK_EVENT("monitorRemoved", this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMonitor::addDamage(const pixman_region32_t* rg) {
|
void CMonitor::addDamage(const pixman_region32_t* rg) {
|
||||||
|
|
Loading…
Reference in a new issue