diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 2d6e7856..68db0091 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2808,6 +2808,8 @@ void CCompositor::enterUnsafeState() { m_pUnsafeOutput->onConnect(false); m_bUnsafeState = true; + + setActiveMonitor(m_pUnsafeOutput); } void CCompositor::leaveUnsafeState() { diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index d1cf9552..0d1665b7 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -53,6 +53,10 @@ void Events::listener_mapWindow(void* owner, void* data) { static auto PNEWTAKESOVERFS = CConfigValue("misc:new_window_takes_over_fullscreen"); auto PMONITOR = g_pCompositor->m_pLastMonitor; + if (!g_pCompositor->m_pLastMonitor) { + g_pCompositor->setActiveMonitor(g_pCompositor->getMonitorFromVector({})); + PMONITOR = g_pCompositor->m_pLastMonitor; + } auto PWORKSPACE = PMONITOR->specialWorkspaceID ? g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID) : g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); PWINDOW->m_iMonitorID = PMONITOR->ID; PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace; diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 3edb7ca4..219257b9 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -310,7 +310,7 @@ void CMonitor::onDisconnect(bool destroy) { Debug::log(WARN, "wlr_output_commit_state failed in CMonitor::onDisconnect"); if (g_pCompositor->m_pLastMonitor == this) - g_pCompositor->setActiveMonitor(BACKUPMON); + g_pCompositor->setActiveMonitor(BACKUPMON ? BACKUPMON : g_pCompositor->m_pUnsafeOutput); if (g_pHyprRenderer->m_pMostHzMonitor == this) { int mostHz = 0;