Skip to content

Commit

Permalink
Extract Niri::advance_animations()
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Nov 23, 2024
1 parent 1e6b890 commit 9c7e8d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl State {
// doesn't always trigger due to damage, etc. So run it here right before it might prove
// important. Besides, animations affect the input, so it's best to have up-to-date values
// here.
self.niri.layout.advance_animations(get_monotonic_time());
self.niri.advance_animations(get_monotonic_time());

if self.niri.monitors_active {
// Notify the idle-notifier of activity.
Expand Down
36 changes: 19 additions & 17 deletions src/niri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3036,6 +3036,22 @@ impl Niri {
}
}

pub fn advance_animations(&mut self, target_time: Duration) {
self.layout.advance_animations(target_time);
self.config_error_notification
.advance_animations(target_time);
self.screenshot_ui.advance_animations(target_time);

for state in self.output_state.values_mut() {
if let Some(transition) = &mut state.screen_transition {
transition.advance_animations(target_time);
if transition.is_done() {
state.screen_transition = None;
}
}
}
}

pub fn update_render_elements(&mut self, output: Option<&Output>) {
self.layout.update_render_elements(output);

Expand Down Expand Up @@ -3243,34 +3259,20 @@ impl Niri {
let mut res = RenderResult::Skipped;
if self.monitors_active {
// Update from the config and advance the animations.
self.layout.advance_animations(target_presentation_time);

if let Some(transition) = &mut state.screen_transition {
transition.advance_animations(target_presentation_time);
if transition.is_done() {
state.screen_transition = None;
}
}
self.advance_animations(target_presentation_time);

let state = self.output_state.get_mut(output).unwrap();
state.unfinished_animations_remain = self.layout.are_animations_ongoing(Some(output));

self.config_error_notification
.advance_animations(target_presentation_time);
state.unfinished_animations_remain |=
self.config_error_notification.are_animations_ongoing();

self.screenshot_ui
.advance_animations(target_presentation_time);
state.unfinished_animations_remain |= self.screenshot_ui.are_animations_ongoing();
state.unfinished_animations_remain |= state.screen_transition.is_some();

// Also keep redrawing if the current cursor is animated.
state.unfinished_animations_remain |= self
.cursor_manager
.is_current_cursor_animated(output.current_scale().integer_scale());

// Also keep redrawing during a screen transition.
state.unfinished_animations_remain |= state.screen_transition.is_some();

self.update_render_elements(Some(output));

// Render.
Expand Down

0 comments on commit 9c7e8d0

Please sign in to comment.