From 37068cf4f0e29313106886478dbf58872407a626 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 3 Aug 2022 17:42:19 +0200 Subject: [PATCH] fix crash with reenabling a monitor --- src/helpers/Monitor.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index dd2db9aa..ac4435b2 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -21,6 +21,17 @@ void CMonitor::onConnect(bool noRule) { return; } + if (!m_pThisWrap) { + + // find the wrap + for (auto& m : g_pCompositor->m_vRealMonitors) { + if (m->ID == ID) { + m_pThisWrap = &m; + break; + } + } + } + if (std::find_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& other) { return other.get() == this; }) == g_pCompositor->m_vMonitors.end()){ g_pCompositor->m_vMonitors.push_back(*m_pThisWrap); } @@ -98,6 +109,8 @@ void CMonitor::onConnect(bool noRule) { activeWorkspace = PNEWWORKSPACE->m_iID; scale = monitorRule.scale; + m_pThisWrap = nullptr; + forceFullFrames = 3; // force 3 full frames to make sure there is no blinking due to double-buffering. g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle);