Skip to content

Commit

Permalink
Delay monitor messages
Browse files Browse the repository at this point in the history
  • Loading branch information
leiserfg committed Sep 15, 2024
1 parent e74efd8 commit aebe9d6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/helpers/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ void CMonitor::onConnect(bool noRule) {
if (!activeMonitorRule.mirrorOf.empty())
setMirror(activeMonitorRule.mirrorOf);

g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName});
g_pEventManager->postEvent(SHyprIPCEvent{"monitoraddedv2", std::format("{},{},{}", ID, szName, szShortDescription)});
EMIT_HOOK_EVENT("monitorAdded", this);

if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet
g_pCompositor->setActiveMonitor(this);
Expand Down Expand Up @@ -224,6 +221,10 @@ void CMonitor::onConnect(bool noRule) {
PROTO::gamma->applyGammaToState(this);

events.connect.emit();

g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName});
g_pEventManager->postEvent(SHyprIPCEvent{"monitoraddedv2", std::format("{},{},{}", ID, szName, szShortDescription)});
EMIT_HOOK_EVENT("monitorAdded", this);
}

void CMonitor::onDisconnect(bool destroy) {
Expand Down Expand Up @@ -281,8 +282,6 @@ void CMonitor::onDisconnect(bool destroy) {

Debug::log(LOG, "Removed monitor {}!", szName);

g_pEventManager->postEvent(SHyprIPCEvent{"monitorremoved", szName});
EMIT_HOOK_EVENT("monitorRemoved", this);

if (!BACKUPMON) {
Debug::log(WARN, "Unplugged last monitor, entering an unsafe state. Good luck my friend.");
Expand Down Expand Up @@ -342,6 +341,9 @@ void CMonitor::onDisconnect(bool destroy) {
g_pHyprRenderer->m_pMostHzMonitor = pMonitorMostHz;
}
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) {
Expand Down

0 comments on commit aebe9d6

Please sign in to comment.