diff options
author | Vaxry <[email protected]> | 2024-03-26 02:26:09 +0000 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-03-26 02:26:19 +0000 |
commit | a9d7526aae38dcdceb391fe9f00919c6c400abe3 (patch) | |
tree | f284e380e2af65a02820f8910ffdcb8104a8535d | |
parent | 414e37996d0c33a5792b8698146792a2a0359b93 (diff) | |
download | Hyprland-a9d7526aae38dcdceb391fe9f00919c6c400abe3.tar.gz Hyprland-a9d7526aae38dcdceb391fe9f00919c6c400abe3.zip |
core: ensure m_pLastMonitor validity over unsafe state
ref #5241
-rw-r--r-- | src/Compositor.cpp | 2 | ||||
-rw-r--r-- | src/events/Windows.cpp | 4 | ||||
-rw-r--r-- | src/helpers/Monitor.cpp | 2 |
3 files changed, 7 insertions, 1 deletions
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<Hyprlang::INT>("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; |