forge
Explore
Log in

Don't you dare go Hollow

layout/monitor: Extract activate_workspace_with_anim_config()

Browse files at this commit

99358e36b38c1aa5cc0c0fb36a91ae7cb4a2e3baIvan MolodetskikhParent: 8b878f3
src/layout/monitor.rsmodified+11 -2
@@ -287,7 +287,15 @@ impl<W: LayoutElement> Monitor<W> {
287 self.add_workspace_at(self.workspaces.len());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 if self.active_workspace_idx == idx {299 if self.active_workspace_idx == idx {
292 return;300 return;
293 }301 }
@@ -299,12 +307,13 @@ impl<W: LayoutElement> Monitor<W> {
299 307
300 self.active_workspace_idx = idx;308 self.active_workspace_idx = idx;
301 309
310+ let config = config.unwrap_or(self.options.animations.workspace_switch.0);
302 self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(311 self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(
303 self.clock.clone(),312 self.clock.clone(),
304 current_idx,313 current_idx,
305 idx as f64,314 idx as f64,
306 0.,315 0.,
307- self.options.animations.workspace_switch.0,316+ config,
308 )));317 )));
309 }318 }
310 319