diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-04 11:10:02 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-04 11:10:02 +0400 |
| commit | 73cc0079d628e66b1d64168ed1a10b13b23ab5d0 (patch) | |
| tree | 168aa5d885c2061c8ec9090e1cd46b865a6f2a42 /src/layout/monitor.rs | |
| parent | 69aeba2a4d93b34eb24319c3694ad354dc608a87 (diff) | |
| download | niri-73cc0079d628e66b1d64168ed1a10b13b23ab5d0.tar.gz niri-73cc0079d628e66b1d64168ed1a10b13b23ab5d0.tar.bz2 niri-73cc0079d628e66b1d64168ed1a10b13b23ab5d0.zip | |
Split update_render_elements() from advance_animations()
advance_animations() is called from places like input, whereas
update_render_elements() is strictly for rendering.
Diffstat (limited to 'src/layout/monitor.rs')
| -rw-r--r-- | src/layout/monitor.rs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index f1e8d542..8d695139 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -523,7 +523,7 @@ impl<W: LayoutElement> Monitor<W> { Some(column.tiles[column.active_tile_idx].window()) } - pub fn advance_animations(&mut self, current_time: Duration, is_active: bool) { + pub fn advance_animations(&mut self, current_time: Duration) { if let Some(WorkspaceSwitch::Animation(anim)) = &mut self.workspace_switch { anim.set_current_time(current_time); if anim.is_done() { @@ -533,7 +533,7 @@ impl<W: LayoutElement> Monitor<W> { } for ws in &mut self.workspaces { - ws.advance_animations(current_time, is_active); + ws.advance_animations(current_time); } } @@ -552,6 +552,35 @@ impl<W: LayoutElement> Monitor<W> { .any(|ws| ws.are_transitions_ongoing()) } + pub fn update_render_elements(&mut self, is_active: bool) { + match &self.workspace_switch { + Some(switch) => { + let render_idx = switch.current_idx(); + let before_idx = render_idx.floor(); + let after_idx = render_idx.ceil(); + + if after_idx < 0. || before_idx as usize >= self.workspaces.len() { + return; + } + + let after_idx = after_idx as usize; + if after_idx < self.workspaces.len() { + self.workspaces[after_idx].update_render_elements(is_active); + + if before_idx < 0. { + return; + } + } + + let before_idx = before_idx as usize; + self.workspaces[before_idx].update_render_elements(is_active); + } + None => { + self.workspaces[self.active_workspace_idx].update_render_elements(is_active); + } + } + } + pub fn update_config(&mut self, options: Rc<Options>) { for ws in &mut self.workspaces { ws.update_config(options.clone()); |
