From 978c1829ae4bfd38eb64d5775a13fcc3c4f58920 Mon Sep 17 00:00:00 2001 From: Harenayo <123649644+harenayo@users.noreply.github.com> Date: Fri, 28 Jun 2024 18:03:10 +0900 Subject: [PATCH 1/2] Fix listener_sessionActive to handle an event correctly when the session get inactivated --- src/events/Misc.cpp | 27 ++++++++++++++++++++------- src/managers/KeybindManager.cpp | 13 +------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/events/Misc.cpp b/src/events/Misc.cpp index 6580d93e61f..73489bc6016 100644 --- a/src/events/Misc.cpp +++ b/src/events/Misc.cpp @@ -30,14 +30,27 @@ void Events::listener_RendererDestroy(wl_listener* listener, void* data) { } void Events::listener_sessionActive(wl_listener* listener, void* data) { - Debug::log(LOG, "Session got activated!"); + if (g_pCompositor->m_sWLRSession->active) { + Debug::log(LOG, "Session got activated!"); - g_pCompositor->m_bSessionActive = true; + g_pCompositor->m_bSessionActive = true; - for (auto& m : g_pCompositor->m_vMonitors) { - g_pCompositor->scheduleFrameForMonitor(m.get()); - g_pHyprRenderer->applyMonitorRule(m.get(), &m->activeMonitorRule, true); - } + for (auto& m : g_pCompositor->m_vMonitors) { + g_pCompositor->scheduleFrameForMonitor(m.get()); + g_pHyprRenderer->applyMonitorRule(m.get(), &m->activeMonitorRule, true); + } + + g_pConfigManager->m_bWantsMonitorReload = true; + } else { + Debug::log(LOG, "Session got inactivated!"); + + g_pCompositor->m_bSessionActive = false; - g_pConfigManager->m_bWantsMonitorReload = true; + for (auto& m : g_pCompositor->m_vMonitors) { + m->noFrameSchedule = true; + m->framesToSkip = 1; + } + + Debug::log(LOG, "Destroyed all render data, frames to skip for each: 2"); + } } diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 005ce3925a0..f66b4457e4c 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -810,18 +810,7 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) { Debug::log(LOG, "Switching from VT {} to VT {}", ttynum, TTY); - if (!wlr_session_change_vt(g_pCompositor->m_sWLRSession, TTY)) - return true; // probably same session - - g_pCompositor->m_bSessionActive = false; - - for (auto& m : g_pCompositor->m_vMonitors) { - m->noFrameSchedule = true; - m->framesToSkip = 1; - } - - Debug::log(LOG, "Switched to VT {}, destroyed all render data, frames to skip for each: 2", TTY); - + wlr_session_change_vt(g_pCompositor->m_sWLRSession, TTY); return true; } From 7c75a36b045c76d5c10d19139bb86f610fa63409 Mon Sep 17 00:00:00 2001 From: Harenayo <123649644+harenayo@users.noreply.github.com> Date: Sat, 29 Jun 2024 09:54:39 +0900 Subject: [PATCH 2/2] Remove log --- src/events/Misc.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/events/Misc.cpp b/src/events/Misc.cpp index 73489bc6016..32f894ec427 100644 --- a/src/events/Misc.cpp +++ b/src/events/Misc.cpp @@ -50,7 +50,5 @@ void Events::listener_sessionActive(wl_listener* listener, void* data) { m->noFrameSchedule = true; m->framesToSkip = 1; } - - Debug::log(LOG, "Destroyed all render data, frames to skip for each: 2"); } }