layout/monitor: Extract activate_workspace_with_anim_config()
Browse files at this commit99358e36b38c1aa5cc0c0fb36a91ae7cb4a2e3baParent: 8b878f31 changed file +11 -2
- src/layout/monitor.rs +11 -2
src/layout/monitor.rsmodified+11 -2
| @@ -287,7 +287,15 @@ impl<W: LayoutElement> Monitor<W> { | ||
| 287 | 287 | self.add_workspace_at(self.workspaces.len()); |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - fn activate_workspace(&mut self, idx: usize) { | |
| 290 | + pub fn activate_workspace(&mut self, idx: usize) { | |
| 291 | + self.activate_workspace_with_anim_config(idx, None); | |
| 292 | + } | |
| 293 | + | |
| 294 | + pub fn activate_workspace_with_anim_config( | |
| 295 | + &mut self, | |
| 296 | + idx: usize, | |
| 297 | + config: Option<niri_config::Animation>, | |
| 298 | + ) { | |
| 291 | 299 | if self.active_workspace_idx == idx { |
| 292 | 300 | return; |
| 293 | 301 | } |
| @@ -299,12 +307,13 @@ impl<W: LayoutElement> Monitor<W> { | ||
| 299 | 307 | |
| 300 | 308 | self.active_workspace_idx = idx; |
| 301 | 309 | |
| 310 | + let config = config.unwrap_or(self.options.animations.workspace_switch.0); | |
| 302 | 311 | self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new( |
| 303 | 312 | self.clock.clone(), |
| 304 | 313 | current_idx, |
| 305 | 314 | idx as f64, |
| 306 | 315 | 0., |
| 307 | - self.options.animations.workspace_switch.0, | |
| 316 | + config, | |
| 308 | 317 | ))); |
| 309 | 318 | } |
| 310 | 319 |