diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-03-02 17:30:47 +0000 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-03-02 17:30:50 +0000 |
| commit | 34685a836a40648167848060b48b62788cdcc85f (patch) | |
| tree | d2f80358ccee9983f56ccf0aa9845083af5f8ba1 /src | |
| parent | dea71875e40d5ff4ad649b3c04b02419b06da5df (diff) | |
Move AnimationManager::tick() to an event loop
Diffstat (limited to 'src')
| -rw-r--r-- | src/events/Monitors.cpp | 1 | ||||
| -rw-r--r-- | src/managers/AnimationManager.cpp | 14 | ||||
| -rw-r--r-- | src/managers/AnimationManager.hpp | 2 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index cafd77f8..13de69a5 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -151,7 +151,6 @@ void Events::listener_monitorFrame(void* owner, void* data) { if (PMONITOR->ID == g_pHyprRenderer->m_pMostHzMonitor->ID || *PVFR == 1) { // unfortunately with VFR we don't have the guarantee mostHz is going to be updated all the time, so we have to ignore that g_pCompositor->sanityCheckWorkspaces(); - g_pAnimationManager->tick(); g_pConfigManager->dispatchExecOnce(); // We exec-once when at least one monitor starts refreshing, meaning stuff has init'd diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 456ae7f7..c2708038 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -1,9 +1,23 @@ #include "AnimationManager.hpp" #include "../Compositor.hpp" +int wlTick(void* data) { + + float refreshRate = g_pHyprRenderer->m_pMostHzMonitor ? g_pHyprRenderer->m_pMostHzMonitor->refreshRate : 60.f; + + wl_event_source_timer_update(g_pAnimationManager->m_pAnimationTick, 1000 / refreshRate); + + g_pAnimationManager->tick(); + + return 0; +} + CAnimationManager::CAnimationManager() { std::vector<Vector2D> points = {Vector2D(0, 0.75f), Vector2D(0.15f, 1.f)}; m_mBezierCurves["default"].setup(&points); + + m_pAnimationTick = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, &wlTick, nullptr); + wl_event_source_timer_update(m_pAnimationTick, 1); } void CAnimationManager::removeAllBeziers() { diff --git a/src/managers/AnimationManager.hpp b/src/managers/AnimationManager.hpp index 77e8acf1..635d51eb 100644 --- a/src/managers/AnimationManager.hpp +++ b/src/managers/AnimationManager.hpp @@ -26,6 +26,8 @@ class CAnimationManager { std::list<CAnimatedVariable*> m_lAnimatedVariables; + wl_event_source* m_pAnimationTick; + private: bool deltaSmallToFlip(const Vector2D& a, const Vector2D& b); bool deltaSmallToFlip(const CColor& a, const CColor& b); |
