Skip to content

Commit befcdad

Browse files
committed
floating: animation fixes
1 parent 7988be1 commit befcdad

File tree

1 file changed

+38
-19
lines changed
  • src/shell/layout/floating

1 file changed

+38
-19
lines changed

src/shell/layout/floating/mod.rs

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,26 @@ impl FloatingLayout {
354354
mapped.moved_since_mapped.store(true, Ordering::SeqCst);
355355

356356
if animate {
357-
self.animations.insert(
358-
mapped.clone(),
359-
Animation::Tiled {
360-
start: Instant::now(),
361-
previous_geometry,
362-
},
363-
);
357+
if let Some(existing_anim) = self.animations.get_mut(&mapped) {
358+
match existing_anim {
359+
Animation::Unminimize {
360+
target_geometry, ..
361+
} => {
362+
*target_geometry = geometry;
363+
}
364+
Animation::Minimize { .. } | Animation::Tiled { .. } => {}
365+
}
366+
} else {
367+
self.animations.insert(
368+
mapped.clone(),
369+
Animation::Tiled {
370+
start: Instant::now(),
371+
previous_geometry,
372+
},
373+
);
374+
}
375+
} else {
376+
self.animations.remove(&mapped);
364377
}
365378
if mapped.floating_tiled.lock().unwrap().take().is_some() {
366379
if let Some(state) = mapped.maximized_state.lock().unwrap().as_mut() {
@@ -631,11 +644,28 @@ impl FloatingLayout {
631644
window: &CosmicMapped,
632645
to: Option<Rectangle<i32, Local>>,
633646
) -> Option<Rectangle<i32, Local>> {
634-
let _ = self.animations.remove(window);
635647
let Some(mut mapped_geometry) = self.space.element_geometry(window).map(RectExt::as_local)
636648
else {
637649
return None;
638650
};
651+
let _ = self.animations.remove(window);
652+
653+
if let Some(to) = to {
654+
self.animations.insert(
655+
window.clone(),
656+
Animation::Minimize {
657+
start: Instant::now(),
658+
previous_geometry: if window.is_maximized(false) {
659+
let output = self.space.outputs().next().unwrap();
660+
let layers = layer_map_for_output(output);
661+
layers.non_exclusive_zone().as_local()
662+
} else {
663+
mapped_geometry
664+
},
665+
target_geometry: to,
666+
},
667+
);
668+
}
639669

640670
if let Some(_) = window.floating_tiled.lock().unwrap().take() {
641671
if let Some(last_size) = window.last_geometry.lock().unwrap().map(|geo| geo.size) {
@@ -652,17 +682,6 @@ impl FloatingLayout {
652682
*window.last_geometry.lock().unwrap() = Some(mapped_geometry);
653683
}
654684

655-
if let Some(to) = to {
656-
self.animations.insert(
657-
window.clone(),
658-
Animation::Minimize {
659-
start: Instant::now(),
660-
previous_geometry: mapped_geometry,
661-
target_geometry: to,
662-
},
663-
);
664-
}
665-
666685
self.space.unmap_elem(&window);
667686
if let Some(pos) = self.spawn_order.iter().position(|w| w == window) {
668687
self.spawn_order.truncate(pos);

0 commit comments

Comments
 (0)