minimize: Slower animation
This commit is contained in:
parent
70cda33481
commit
4f55f4127b
2 changed files with 31 additions and 18 deletions
|
|
@ -47,6 +47,7 @@ mod grabs;
|
||||||
pub use self::grabs::*;
|
pub use self::grabs::*;
|
||||||
|
|
||||||
pub const ANIMATION_DURATION: Duration = Duration::from_millis(200);
|
pub const ANIMATION_DURATION: Duration = Duration::from_millis(200);
|
||||||
|
pub const MINIMIZE_ANIMATION_DURATION: Duration = Duration::from_millis(300);
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct FloatingLayout {
|
pub struct FloatingLayout {
|
||||||
|
|
@ -91,16 +92,16 @@ impl Animation {
|
||||||
Animation::Minimize { start, .. } => {
|
Animation::Minimize { start, .. } => {
|
||||||
1.0 - (Instant::now()
|
1.0 - (Instant::now()
|
||||||
.duration_since(*start)
|
.duration_since(*start)
|
||||||
.min(ANIMATION_DURATION)
|
.min(MINIMIZE_ANIMATION_DURATION)
|
||||||
.as_secs_f32()
|
.as_secs_f32()
|
||||||
/ ANIMATION_DURATION.as_secs_f32())
|
/ MINIMIZE_ANIMATION_DURATION.as_secs_f32())
|
||||||
}
|
}
|
||||||
Animation::Unminimize { start, .. } => {
|
Animation::Unminimize { start, .. } => {
|
||||||
Instant::now()
|
Instant::now()
|
||||||
.duration_since(*start)
|
.duration_since(*start)
|
||||||
.min(ANIMATION_DURATION)
|
.min(MINIMIZE_ANIMATION_DURATION)
|
||||||
.as_secs_f32()
|
.as_secs_f32()
|
||||||
/ ANIMATION_DURATION.as_secs_f32()
|
/ MINIMIZE_ANIMATION_DURATION.as_secs_f32()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -125,31 +126,29 @@ impl Animation {
|
||||||
current_geometry: Rectangle<i32, Local>,
|
current_geometry: Rectangle<i32, Local>,
|
||||||
tiled_state: Option<&TiledCorners>,
|
tiled_state: Option<&TiledCorners>,
|
||||||
) -> Rectangle<i32, Local> {
|
) -> Rectangle<i32, Local> {
|
||||||
let target_rect = match self {
|
let (duration, target_rect) = match self {
|
||||||
Animation::Minimize {
|
Animation::Minimize {
|
||||||
target_geometry, ..
|
target_geometry, ..
|
||||||
}
|
}
|
||||||
| Animation::Unminimize {
|
| Animation::Unminimize {
|
||||||
target_geometry, ..
|
target_geometry, ..
|
||||||
} => target_geometry.clone(),
|
} => (MINIMIZE_ANIMATION_DURATION, target_geometry.clone()),
|
||||||
Animation::Tiled { .. } => {
|
Animation::Tiled { .. } => {
|
||||||
if let Some(target_rect) =
|
let target_geometry = if let Some(target_rect) =
|
||||||
tiled_state.map(|state| state.relative_geometry(output_geometry))
|
tiled_state.map(|state| state.relative_geometry(output_geometry))
|
||||||
{
|
{
|
||||||
target_rect
|
target_rect
|
||||||
} else {
|
} else {
|
||||||
current_geometry
|
current_geometry
|
||||||
}
|
};
|
||||||
|
(ANIMATION_DURATION, target_geometry)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let previous_rect = self.previous_geometry().clone();
|
let previous_rect = self.previous_geometry().clone();
|
||||||
let start = *self.start();
|
let start = *self.start();
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let progress = now
|
let progress =
|
||||||
.duration_since(start)
|
now.duration_since(start).min(duration).as_secs_f64() / duration.as_secs_f64();
|
||||||
.min(ANIMATION_DURATION)
|
|
||||||
.as_secs_f64()
|
|
||||||
/ ANIMATION_DURATION.as_secs_f64();
|
|
||||||
|
|
||||||
ease(
|
ease(
|
||||||
EaseInOutCubic,
|
EaseInOutCubic,
|
||||||
|
|
@ -1107,8 +1106,13 @@ impl FloatingLayout {
|
||||||
|
|
||||||
pub fn update_animation_state(&mut self) {
|
pub fn update_animation_state(&mut self) {
|
||||||
let was_empty = self.animations.is_empty();
|
let was_empty = self.animations.is_empty();
|
||||||
self.animations
|
self.animations.retain(|_, anim| {
|
||||||
.retain(|_, anim| Instant::now().duration_since(*anim.start()) < ANIMATION_DURATION);
|
let duration = match anim {
|
||||||
|
Animation::Tiled { .. } => ANIMATION_DURATION,
|
||||||
|
_ => MINIMIZE_ANIMATION_DURATION,
|
||||||
|
};
|
||||||
|
Instant::now().duration_since(*anim.start()) < duration
|
||||||
|
});
|
||||||
if self.animations.is_empty() != was_empty {
|
if self.animations.is_empty() != was_empty {
|
||||||
self.dirty.store(true, Ordering::SeqCst);
|
self.dirty.store(true, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ pub use self::blocker::*;
|
||||||
pub use self::grabs::*;
|
pub use self::grabs::*;
|
||||||
|
|
||||||
pub const ANIMATION_DURATION: Duration = Duration::from_millis(200);
|
pub const ANIMATION_DURATION: Duration = Duration::from_millis(200);
|
||||||
|
pub const MINIMIZE_ANIMATION_DURATION: Duration = Duration::from_millis(300);
|
||||||
pub const MOUSE_ANIMATION_DELAY: Duration = Duration::from_millis(150);
|
pub const MOUSE_ANIMATION_DELAY: Duration = Duration::from_millis(150);
|
||||||
pub const INITIAL_MOUSE_ANIMATION_DELAY: Duration = Duration::from_millis(500);
|
pub const INITIAL_MOUSE_ANIMATION_DELAY: Duration = Duration::from_millis(500);
|
||||||
|
|
||||||
|
|
@ -395,6 +396,12 @@ impl TilingLayout {
|
||||||
let last_active = focus_stack
|
let last_active = focus_stack
|
||||||
.and_then(|focus_stack| TilingLayout::last_active_window(&mut tree, focus_stack))
|
.and_then(|focus_stack| TilingLayout::last_active_window(&mut tree, focus_stack))
|
||||||
.map(|(node_id, _)| node_id);
|
.map(|(node_id, _)| node_id);
|
||||||
|
let duration = if minimize_rect.is_some() {
|
||||||
|
MINIMIZE_ANIMATION_DURATION
|
||||||
|
} else {
|
||||||
|
ANIMATION_DURATION
|
||||||
|
};
|
||||||
|
|
||||||
TilingLayout::map_to_tree(
|
TilingLayout::map_to_tree(
|
||||||
&mut tree,
|
&mut tree,
|
||||||
window,
|
window,
|
||||||
|
|
@ -404,7 +411,7 @@ impl TilingLayout {
|
||||||
minimize_rect,
|
minimize_rect,
|
||||||
);
|
);
|
||||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||||
self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
|
self.queue.push_tree(tree, duration, blocker);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remap_minimized<'a>(
|
pub fn remap_minimized<'a>(
|
||||||
|
|
@ -469,7 +476,8 @@ impl TilingLayout {
|
||||||
*window.tiling_node_id.lock().unwrap() = Some(new_id);
|
*window.tiling_node_id.lock().unwrap() = Some(new_id);
|
||||||
|
|
||||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||||
self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
|
self.queue
|
||||||
|
.push_tree(tree, MINIMIZE_ANIMATION_DURATION, blocker);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -507,7 +515,8 @@ impl TilingLayout {
|
||||||
*window.tiling_node_id.lock().unwrap() = Some(new_id);
|
*window.tiling_node_id.lock().unwrap() = Some(new_id);
|
||||||
|
|
||||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||||
self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
|
self.queue
|
||||||
|
.push_tree(tree, MINIMIZE_ANIMATION_DURATION, blocker);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue