diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-23 11:27:27 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-25 04:07:59 -0800 |
| commit | 93cee2994ab9ccf59a09f61d5b8acf6cd937d654 (patch) | |
| tree | fb00cdb266e9e94891f226558cd93a09e0091d69 /src/niri.rs | |
| parent | 9c7e8d04d27d2f914ad3e9a54c64b64c34aea4d4 (diff) | |
| download | niri-93cee2994ab9ccf59a09f61d5b8acf6cd937d654.tar.gz niri-93cee2994ab9ccf59a09f61d5b8acf6cd937d654.tar.bz2 niri-93cee2994ab9ccf59a09f61d5b8acf6cd937d654.zip | |
Refactor animations to take explicit current time
Diffstat (limited to 'src/niri.rs')
| -rw-r--r-- | src/niri.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/niri.rs b/src/niri.rs index 7a579761..57050d6d 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -100,6 +100,7 @@ use smithay::wayland::virtual_keyboard::VirtualKeyboardManagerState; use smithay::wayland::xdg_activation::XdgActivationState; use smithay::wayland::xdg_foreign::XdgForeignState; +use crate::animation::Clock; use crate::backend::tty::SurfaceDmabufFeedback; use crate::backend::{Backend, RenderResult, Tty, Winit}; use crate::cursor::{CursorManager, CursorTextureCache, RenderCursor, XCursor}; @@ -179,6 +180,9 @@ pub struct Niri { /// Whether the at-startup=true window rules are active. pub is_at_startup: bool, + /// Clock for driving animations. + pub clock: Clock, + // Each workspace corresponds to a Space. Each workspace generally has one Output mapped to it, // however it may have none (when there are no outputs connected) or multiple (when mirroring). pub layout: Layout<Mapped>, @@ -1671,7 +1675,8 @@ impl Niri { let config_ = config.borrow(); let config_file_output_config = config_.outputs.clone(); - let layout = Layout::new(&config_); + let clock = Clock::default(); + let layout = Layout::new(clock.clone(), &config_); let (blocker_cleared_tx, blocker_cleared_rx) = mpsc::channel(); @@ -1799,8 +1804,8 @@ impl Niri { let mods_with_finger_scroll_binds = mods_with_finger_scroll_binds(backend.mod_key(), &config_.binds); - let screenshot_ui = ScreenshotUi::new(config.clone()); - let config_error_notification = ConfigErrorNotification::new(config.clone()); + let screenshot_ui = ScreenshotUi::new(clock.clone(), config.clone()); + let config_error_notification = ConfigErrorNotification::new(clock.clone(), config.clone()); let mut hotkey_overlay = HotkeyOverlay::new(config.clone(), backend.mod_key()); if !config_.hotkey_overlay.skip_at_startup { @@ -1895,6 +1900,7 @@ impl Niri { display_handle, start_time: Instant::now(), is_at_startup: true, + clock, layout, global_space: Space::default(), @@ -3044,6 +3050,7 @@ impl Niri { for state in self.output_state.values_mut() { if let Some(transition) = &mut state.screen_transition { + // Screen transition uses real time so that it's not affected by animation slowdown. transition.advance_animations(target_time); if transition.is_done() { state.screen_transition = None; @@ -4819,6 +4826,8 @@ impl Niri { let delay = delay_ms.map_or(screen_transition::DELAY, |d| { Duration::from_millis(u64::from(d)) }); + + // Screen transition uses real time so that it's not affected by animation slowdown. let start_at = get_monotonic_time() + delay; for (output, from_texture) in textures { let state = self.output_state.get_mut(&output).unwrap(); |
