From 73cc0079d628e66b1d64168ed1a10b13b23ab5d0 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sat, 4 May 2024 11:10:02 +0400 Subject: Split update_render_elements() from advance_animations() advance_animations() is called from places like input, whereas update_render_elements() is strictly for rendering. --- src/layout/monitor.rs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'src/layout/monitor.rs') 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 Monitor { 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 Monitor { } for ws in &mut self.workspaces { - ws.advance_animations(current_time, is_active); + ws.advance_animations(current_time); } } @@ -552,6 +552,35 @@ impl Monitor { .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) { for ws in &mut self.workspaces { ws.update_config(options.clone()); -- cgit