core: ensure m_pLastMonitor validity over unsafe state

ref #5241
This commit is contained in:
Vaxry 2024-03-26 02:26:09 +00:00
parent 414e37996d
commit a9d7526aae
3 changed files with 7 additions and 1 deletions

View file

@ -2808,6 +2808,8 @@ void CCompositor::enterUnsafeState() {
m_pUnsafeOutput->onConnect(false); m_pUnsafeOutput->onConnect(false);
m_bUnsafeState = true; m_bUnsafeState = true;
setActiveMonitor(m_pUnsafeOutput);
} }
void CCompositor::leaveUnsafeState() { void CCompositor::leaveUnsafeState() {

View file

@ -53,6 +53,10 @@ void Events::listener_mapWindow(void* owner, void* data) {
static auto PNEWTAKESOVERFS = CConfigValue<Hyprlang::INT>("misc:new_window_takes_over_fullscreen"); static auto PNEWTAKESOVERFS = CConfigValue<Hyprlang::INT>("misc:new_window_takes_over_fullscreen");
auto PMONITOR = g_pCompositor->m_pLastMonitor; 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); auto PWORKSPACE = PMONITOR->specialWorkspaceID ? g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID) : g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
PWINDOW->m_iMonitorID = PMONITOR->ID; PWINDOW->m_iMonitorID = PMONITOR->ID;
PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace; PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace;

View file

@ -310,7 +310,7 @@ void CMonitor::onDisconnect(bool destroy) {
Debug::log(WARN, "wlr_output_commit_state failed in CMonitor::onDisconnect"); Debug::log(WARN, "wlr_output_commit_state failed in CMonitor::onDisconnect");
if (g_pCompositor->m_pLastMonitor == this) 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) { if (g_pHyprRenderer->m_pMostHzMonitor == this) {
int mostHz = 0; int mostHz = 0;