From e73df80782593f0cab39a5f3e7a5a005203c9b0c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 31 May 2022 17:17:44 +0200 Subject: [PATCH] Add mon in mon out events and fix crash --- src/Compositor.cpp | 5 +++-- src/events/Monitors.cpp | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 4dfb5297f..f7f1d68f4 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1053,8 +1053,9 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, SMonitor* pMoni if (SWITCHINGISACTIVE) { // if it was active, preserve its' status. If it wasn't, don't. Debug::log(LOG, "moveWorkspaceToMonitor: SWITCHINGISACTIVE, active %d -> %d", pMonitor->activeWorkspace, pWorkspace->m_iID); - - getWorkspaceByID(pMonitor->activeWorkspace)->startAnim(false, false); + + if (const auto PWORKSPACE = getWorkspaceByID(pMonitor->activeWorkspace); PWORKSPACE) + getWorkspaceByID(pMonitor->activeWorkspace)->startAnim(false, false); pMonitor->activeWorkspace = pWorkspace->m_iID; g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitor->ID); diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 43e861d0a..e3b0b1909 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -141,7 +141,9 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { // if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet - g_pCompositor->m_pLastMonitor = PNEWMONITOR; + g_pCompositor->m_pLastMonitor = PNEWMONITOR; + + g_pEventManager->postEvent(SHyprIPCEvent("monitoradded", PNEWMONITOR->szName)); // ready to process cuz we have a monitor g_pCompositor->m_bReadyToProcess = true; @@ -341,6 +343,8 @@ void Events::listener_monitorDestroy(void* owner, void* data) { Debug::log(LOG, "Removed monitor %s!", pMonitor->szName.c_str()); + g_pEventManager->postEvent(SHyprIPCEvent("monitorremoved", pMonitor->szName)); + g_pCompositor->m_lMonitors.remove(*pMonitor); // update the pMostHzMonitor