From 625218bbf660527103407de9819f98144946b140 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Thu, 29 Feb 2024 17:50:05 +0100 Subject: [PATCH] shell: Delay alpha changes for minimize animations --- src/shell/layout/floating/mod.rs | 10 ++++++---- src/shell/layout/tiling/mod.rs | 9 +++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index 57e016e6..3b5bf58f 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -90,18 +90,20 @@ impl Animation { match self { Animation::Tiled { .. } => 1.0, Animation::Minimize { start, .. } => { - 1.0 - (Instant::now() + let percentage = Instant::now() .duration_since(*start) .min(MINIMIZE_ANIMATION_DURATION) .as_secs_f32() - / MINIMIZE_ANIMATION_DURATION.as_secs_f32()) + / MINIMIZE_ANIMATION_DURATION.as_secs_f32(); + 1.0 - ((percentage - 0.5).max(0.0) * 2.0) } Animation::Unminimize { start, .. } => { - Instant::now() + let percentage = Instant::now() .duration_since(*start) .min(MINIMIZE_ANIMATION_DURATION) .as_secs_f32() - / MINIMIZE_ANIMATION_DURATION.as_secs_f32() + / MINIMIZE_ANIMATION_DURATION.as_secs_f32(); + (percentage * 2.0).min(1.0) } } } diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index 3f53258d..ba797e90 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -4731,6 +4731,11 @@ where }) .unwrap_or(*original_geo); + let alpha = if minimize_geo.is_some() { + 1.0 - ((percentage - 0.5).max(0.0) * 2.0) + } else { + 1.0 - percentage + }; let elem_geometry = mapped.geometry().to_physical_precise_round(output_scale); let (w_elements, p_elements) = mapped @@ -4739,7 +4744,7 @@ where geo.loc.as_logical().to_physical_precise_round(output_scale) - elem_geometry.loc, Scale::from(output_scale), - 1.0 - percentage, + alpha, ); window_elements.extend(w_elements.into_iter().flat_map(|element| { @@ -5021,7 +5026,7 @@ where .. } = &data { - old_geo = Some((*minimize_rect, percentage)); + old_geo = Some((*minimize_rect, (percentage * 2.0).min(1.0))); } let (scale, offset) = scaled_geo