shell: Delay alpha changes for minimize animations

This commit is contained in:
Victoria Brekenfeld 2024-02-29 17:50:05 +01:00 • committed by Victoria Brekenfeld
parent e669396fd5
commit 625218bbf6
2 changed files with 13 additions and 6 deletions

View file

@ -90,18 +90,20 @@ impl Animation {
match self { match self {
Animation::Tiled { .. } => 1.0, Animation::Tiled { .. } => 1.0,
Animation::Minimize { start, .. } => { Animation::Minimize { start, .. } => {
1.0 - (Instant::now() let percentage = Instant::now()
.duration_since(*start) .duration_since(*start)
.min(MINIMIZE_ANIMATION_DURATION) .min(MINIMIZE_ANIMATION_DURATION)
.as_secs_f32() .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, .. } => { Animation::Unminimize { start, .. } => {
Instant::now() let percentage = Instant::now()
.duration_since(*start) .duration_since(*start)
.min(MINIMIZE_ANIMATION_DURATION) .min(MINIMIZE_ANIMATION_DURATION)
.as_secs_f32() .as_secs_f32()
/ MINIMIZE_ANIMATION_DURATION.as_secs_f32() / MINIMIZE_ANIMATION_DURATION.as_secs_f32();
(percentage * 2.0).min(1.0)
} }
} }
} }

View file

@ -4731,6 +4731,11 @@ where
}) })
.unwrap_or(*original_geo); .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 elem_geometry = mapped.geometry().to_physical_precise_round(output_scale);
let (w_elements, p_elements) = mapped let (w_elements, p_elements) = mapped
@ -4739,7 +4744,7 @@ where
geo.loc.as_logical().to_physical_precise_round(output_scale) geo.loc.as_logical().to_physical_precise_round(output_scale)
- elem_geometry.loc, - elem_geometry.loc,
Scale::from(output_scale), Scale::from(output_scale),
1.0 - percentage, alpha,
); );
window_elements.extend(w_elements.into_iter().flat_map(|element| { window_elements.extend(w_elements.into_iter().flat_map(|element| {
@ -5021,7 +5026,7 @@ where
.. ..
} = &data } = &data
{ {
old_geo = Some((*minimize_rect, percentage)); old_geo = Some((*minimize_rect, (percentage * 2.0).min(1.0)));
} }
let (scale, offset) = scaled_geo let (scale, offset) = scaled_geo