diff --git a/Userland/Services/WindowServer/Animation.cpp b/Userland/Services/WindowServer/Animation.cpp index 7ff6197a252..633331c1568 100644 --- a/Userland/Services/WindowServer/Animation.cpp +++ b/Userland/Services/WindowServer/Animation.cpp @@ -29,6 +29,7 @@ void Animation::start() { m_running = true; m_timer.start(); + Compositor::the().animation_started({}); } void Animation::stop() diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index ac28b4315bc..5ab367ff808 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -528,11 +528,16 @@ void Compositor::compose() m_invalidated_window = false; m_invalidated_cursor = false; - Screen::for_each([&](auto& screen) { - auto& screen_data = m_screen_data[screen.index()]; - update_animations(screen, screen_data.m_flush_special_rects); - return IterationDecision::Continue; - }); + if (!m_animations.is_empty()) { + Screen::for_each([&](auto& screen) { + auto& screen_data = m_screen_data[screen.index()]; + update_animations(screen, screen_data.m_flush_special_rects); + return IterationDecision::Continue; + }); + // As long as animations are running make sure we keep rendering frames + m_invalidated_any = true; + start_compose_async_timer(); + } if (need_to_draw_cursor) { auto& screen_data = m_screen_data[cursor_screen.index()]; @@ -1205,8 +1210,17 @@ void Compositor::recompute_occlusions() void Compositor::register_animation(Badge, Animation& animation) { + bool was_empty = m_animations.is_empty(); auto result = m_animations.set(&animation); VERIFY(result == AK::HashSetResult::InsertedNewEntry); + if (was_empty) + start_compose_async_timer(); +} + +void Compositor::animation_started(Badge) +{ + m_invalidated_any = true; + start_compose_async_timer(); } void Compositor::unregister_animation(Badge, Animation& animation) diff --git a/Userland/Services/WindowServer/Compositor.h b/Userland/Services/WindowServer/Compositor.h index 75a046f4811..3d9e719cb62 100644 --- a/Userland/Services/WindowServer/Compositor.h +++ b/Userland/Services/WindowServer/Compositor.h @@ -71,6 +71,7 @@ public: invalidate_screen(); } + void animation_started(Badge); void invalidate_occlusions() { m_occlusions_dirty = true; } void overlay_rects_changed();