Skip to content

Commit 85bb13e

Browse files
tomutaawesomekling
authored andcommitted
WindowServer: Fix animations not triggering rendering
When starting the first animation and while animations are ongoing we need to make sure we trigger rendering.
1 parent ab88f4e commit 85bb13e

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

Userland/Services/WindowServer/Animation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void Animation::start()
2929
{
3030
m_running = true;
3131
m_timer.start();
32+
Compositor::the().animation_started({});
3233
}
3334

3435
void Animation::stop()

Userland/Services/WindowServer/Compositor.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,16 @@ void Compositor::compose()
528528
m_invalidated_window = false;
529529
m_invalidated_cursor = false;
530530

531-
Screen::for_each([&](auto& screen) {
532-
auto& screen_data = m_screen_data[screen.index()];
533-
update_animations(screen, screen_data.m_flush_special_rects);
534-
return IterationDecision::Continue;
535-
});
531+
if (!m_animations.is_empty()) {
532+
Screen::for_each([&](auto& screen) {
533+
auto& screen_data = m_screen_data[screen.index()];
534+
update_animations(screen, screen_data.m_flush_special_rects);
535+
return IterationDecision::Continue;
536+
});
537+
// As long as animations are running make sure we keep rendering frames
538+
m_invalidated_any = true;
539+
start_compose_async_timer();
540+
}
536541

537542
if (need_to_draw_cursor) {
538543
auto& screen_data = m_screen_data[cursor_screen.index()];
@@ -1205,8 +1210,17 @@ void Compositor::recompute_occlusions()
12051210

12061211
void Compositor::register_animation(Badge<Animation>, Animation& animation)
12071212
{
1213+
bool was_empty = m_animations.is_empty();
12081214
auto result = m_animations.set(&animation);
12091215
VERIFY(result == AK::HashSetResult::InsertedNewEntry);
1216+
if (was_empty)
1217+
start_compose_async_timer();
1218+
}
1219+
1220+
void Compositor::animation_started(Badge<Animation>)
1221+
{
1222+
m_invalidated_any = true;
1223+
start_compose_async_timer();
12101224
}
12111225

12121226
void Compositor::unregister_animation(Badge<Animation>, Animation& animation)

Userland/Services/WindowServer/Compositor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Compositor final : public Core::Object {
7171
invalidate_screen();
7272
}
7373

74+
void animation_started(Badge<Animation>);
7475
void invalidate_occlusions() { m_occlusions_dirty = true; }
7576
void overlay_rects_changed();
7677

0 commit comments

Comments
 (0)