diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 1eb9a43c..b0949d89 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -190,6 +190,7 @@ void CCompositor::initAllSignals() { addWLSignal(&m_sWLRVirtPtrMgr->events.new_virtual_pointer, &Events::listen_newVirtPtr, m_sWLRVirtPtrMgr, "VirtPtrMgr"); addWLSignal(&m_sWLRRenderer->events.destroy, &Events::listen_RendererDestroy, m_sWLRRenderer, "WLRRenderer"); addWLSignal(&m_sWLRIdleInhibitMgr->events.new_inhibitor, &Events::listen_newIdleInhibitor, m_sWLRIdleInhibitMgr, "WLRIdleInhibitMgr"); + addWLSignal(&m_sWLRSession->events.active, &Events::listen_sessionActive, m_sWLRSession, "Session"); } void CCompositor::cleanup() { @@ -1343,3 +1344,10 @@ void CCompositor::updateWorkspaceWindowDecos(const int& id) { w->updateWindowDecos(); } } + +void CCompositor::scheduleFrameForMonitor(SMonitor* pMonitor) { + if (!m_sWLRSession->active || !m_bSessionActive) + return; + + wlr_output_schedule_frame(pMonitor->output); +} \ No newline at end of file diff --git a/src/Compositor.hpp b/src/Compositor.hpp index d49a8dbf..3ea1711a 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -91,6 +91,7 @@ public: SSeat m_sSeat; bool m_bReadyToProcess = false; + bool m_bSessionActive = true; // ------------------------------------------------- // @@ -144,6 +145,7 @@ public: void setWindowFullscreen(CWindow*, bool, eFullscreenMode); void moveUnmanagedX11ToWindows(CWindow*); CWindow* getX11Parent(CWindow*); + void scheduleFrameForMonitor(SMonitor*); private: void initAllSignals(); diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 3dffab12..15140183 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -278,7 +278,7 @@ std::string getRequestFromThread(std::string rq) { // this might be a race condition // tested with 2 instances of `watch -n 0.1 hyprctl splash` and seems to not crash so I'll take that as a yes if (!*PNOVFR) - wlr_output_schedule_frame(g_pCompositor->m_vMonitors.front()->output); + g_pCompositor->scheduleFrameForMonitor(g_pCompositor->m_vMonitors.front().get()); while (HyprCtl::request != "" || HyprCtl::requestMade || HyprCtl::requestReady) { std::this_thread::sleep_for(std::chrono::milliseconds(5)); diff --git a/src/events/Events.hpp b/src/events/Events.hpp index eefc55c7..63e65fdc 100644 --- a/src/events/Events.hpp +++ b/src/events/Events.hpp @@ -119,4 +119,7 @@ namespace Events { LISTENER(swipeBegin); LISTENER(swipeEnd); LISTENER(swipeUpdate); + + // session + LISTENER(sessionActive); }; \ No newline at end of file diff --git a/src/events/Misc.cpp b/src/events/Misc.cpp index c25b1c6a..503d2111 100644 --- a/src/events/Misc.cpp +++ b/src/events/Misc.cpp @@ -157,4 +157,10 @@ void Events::listener_InhibitDeactivate(wl_listener* listener, void* data) { void Events::listener_RendererDestroy(wl_listener* listener, void* data) { Debug::log(LOG, "!!Renderer destroyed!!"); +} + +void Events::listener_sessionActive(wl_listener* listener, void* data) { + Debug::log(LOG, "Session got activated!"); + + g_pCompositor->m_bSessionActive = true; } \ No newline at end of file diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index fa259a0f..949d4585 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -166,7 +166,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { void Events::listener_monitorFrame(void* owner, void* data) { SMonitor* const PMONITOR = (SMonitor*)owner; - if (!g_pCompositor->m_sWLRSession->active) { + if (!g_pCompositor->m_sWLRSession->active || !g_pCompositor->m_bSessionActive) { Debug::log(WARN, "Attempted to render frame on inactive session!"); return; // cannot draw on session inactive (different tty) } @@ -191,7 +191,7 @@ void Events::listener_monitorFrame(void* owner, void* data) { PMONITOR->framesToSkip -= 1; if (!PMONITOR->noFrameSchedule) - wlr_output_schedule_frame(PMONITOR->output); + g_pCompositor->scheduleFrameForMonitor(PMONITOR); else { Debug::log(LOG, "NoFrameSchedule hit for %s.", PMONITOR->szName.c_str()); } @@ -241,7 +241,7 @@ void Events::listener_monitorFrame(void* owner, void* data) { wlr_output_rollback(PMONITOR->output); if (*PDAMAGEBLINK || *PNOVFR) - wlr_output_schedule_frame(PMONITOR->output); + g_pCompositor->scheduleFrameForMonitor(PMONITOR); return; } @@ -331,7 +331,7 @@ void Events::listener_monitorFrame(void* owner, void* data) { wlr_output_commit(PMONITOR->output); if (*PDAMAGEBLINK || *PNOVFR) - wlr_output_schedule_frame(PMONITOR->output); + g_pCompositor->scheduleFrameForMonitor(PMONITOR); if (*PDEBUGOVERLAY == 1) { const float µs = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - startRender).count() / 1000.f; diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 82fb8392..053267e3 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -195,7 +195,7 @@ void CAnimationManager::tick() { g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv()); // manually schedule a frame - wlr_output_schedule_frame(PMONITOR->output); + g_pCompositor->scheduleFrameForMonitor(PMONITOR); } } diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index c5cc5c56..60e4cdd6 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -140,6 +140,7 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) { if (PSESSION) { const int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1; wlr_session_change_vt(PSESSION, TTY); + g_pCompositor->m_bSessionActive = false; for (auto& m : g_pCompositor->m_vMonitors) { m->noFrameSchedule = true; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index e3a0f227..d2b5efa9 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -599,7 +599,7 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) { // schedule frame events if (!wl_list_empty(&pSurface->current.frame_callback_list)) { - wlr_output_schedule_frame(g_pCompositor->getMonitorFromVector(Vector2D(x, y))->output); + g_pCompositor->scheduleFrameForMonitor(g_pCompositor->getMonitorFromVector(Vector2D(x, y))); } if (!pixman_region32_not_empty(&damageBox)) {