From f8a6799d4e41662f8a624da3e4eb3622161dd705 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 12 Dec 2022 20:51:20 +0000 Subject: [PATCH] verify lastmon status on connect --- src/helpers/Monitor.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index f5ddee30..d7daa355 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -142,6 +142,18 @@ void CMonitor::onConnect(bool noRule) { // ensure VRR (will enable if necessary) g_pConfigManager->ensureVRR(this); + + // verify last mon valid + bool found = false; + for (auto& m : g_pCompositor->m_vMonitors) { + if (m.get() == g_pCompositor->m_pLastMonitor) { + found = true; + break; + } + } + + if (!found) + g_pCompositor->setActiveMonitor(this); } void CMonitor::onDisconnect() {