From befcdadf889cb6ad4edf0c107249973ec5983b68 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Fri, 4 Jul 2025 19:27:48 +0200 Subject: [PATCH] floating: animation fixes --- src/shell/layout/floating/mod.rs | 57 +++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index e8002e19..adbee3b8 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -354,13 +354,26 @@ impl FloatingLayout { mapped.moved_since_mapped.store(true, Ordering::SeqCst); if animate { - self.animations.insert( - mapped.clone(), - Animation::Tiled { - start: Instant::now(), - previous_geometry, - }, - ); + if let Some(existing_anim) = self.animations.get_mut(&mapped) { + match existing_anim { + Animation::Unminimize { + target_geometry, .. + } => { + *target_geometry = geometry; + } + Animation::Minimize { .. } | Animation::Tiled { .. } => {} + } + } else { + self.animations.insert( + mapped.clone(), + Animation::Tiled { + start: Instant::now(), + previous_geometry, + }, + ); + } + } else { + self.animations.remove(&mapped); } if mapped.floating_tiled.lock().unwrap().take().is_some() { if let Some(state) = mapped.maximized_state.lock().unwrap().as_mut() { @@ -631,11 +644,28 @@ impl FloatingLayout { window: &CosmicMapped, to: Option>, ) -> Option> { - let _ = self.animations.remove(window); let Some(mut mapped_geometry) = self.space.element_geometry(window).map(RectExt::as_local) else { return None; }; + let _ = self.animations.remove(window); + + if let Some(to) = to { + self.animations.insert( + window.clone(), + Animation::Minimize { + start: Instant::now(), + previous_geometry: if window.is_maximized(false) { + let output = self.space.outputs().next().unwrap(); + let layers = layer_map_for_output(output); + layers.non_exclusive_zone().as_local() + } else { + mapped_geometry + }, + target_geometry: to, + }, + ); + } if let Some(_) = window.floating_tiled.lock().unwrap().take() { if let Some(last_size) = window.last_geometry.lock().unwrap().map(|geo| geo.size) { @@ -652,17 +682,6 @@ impl FloatingLayout { *window.last_geometry.lock().unwrap() = Some(mapped_geometry); } - if let Some(to) = to { - self.animations.insert( - window.clone(), - Animation::Minimize { - start: Instant::now(), - previous_geometry: mapped_geometry, - target_geometry: to, - }, - ); - } - self.space.unmap_elem(&window); if let Some(pos) = self.spawn_order.iter().position(|w| w == window) { self.spawn_order.truncate(pos);