Add float tile transition animations
This commit is contained in:
parent
18ffaef64d
commit
aeaea3419f
5 changed files with 93 additions and 12 deletions
47
src/state.rs
47
src/state.rs
|
|
@ -270,6 +270,7 @@ pub struct State {
|
|||
pub animations: AnimationState,
|
||||
pub layout_animations_requested: Cell<bool>,
|
||||
pub layout_animations_active: Cell<bool>,
|
||||
pub layout_animation_curve_override: Cell<Option<AnimationCurve>>,
|
||||
pub suppress_animations_for_next_layout: Cell<bool>,
|
||||
pub toplevels: CopyHashMap<ToplevelIdentifier, Weak<dyn ToplevelNode>>,
|
||||
pub const_40hz_latch: EventSource<dyn LatchListener>,
|
||||
|
|
@ -854,7 +855,7 @@ impl State {
|
|||
mut height: i32,
|
||||
workspace: &Rc<WorkspaceNode>,
|
||||
abs_pos: Option<(i32, i32)>,
|
||||
) {
|
||||
) -> Rc<FloatNode> {
|
||||
width += 2 * self.theme.sizes.border_width.get();
|
||||
height +=
|
||||
2 * self.theme.sizes.border_width.get() + self.theme.title_plus_underline_height();
|
||||
|
|
@ -885,8 +886,9 @@ impl State {
|
|||
}
|
||||
Rect::new_sized_saturating(x1, y1, width, height)
|
||||
};
|
||||
FloatNode::new(self, workspace, position, node.clone());
|
||||
let float = FloatNode::new(self, workspace, position, node.clone());
|
||||
self.focus_after_map(node, self.seat_queue.last().as_deref());
|
||||
float
|
||||
}
|
||||
|
||||
fn focus_after_map(&self, node: Rc<dyn ToplevelNode>, seat: Option<&Rc<WlSeatGlobal>>) {
|
||||
|
|
@ -1125,6 +1127,7 @@ impl State {
|
|||
self.animations.clear();
|
||||
self.layout_animations_requested.set(false);
|
||||
self.layout_animations_active.set(false);
|
||||
self.layout_animation_curve_override.set(None);
|
||||
self.suppress_animations_for_next_layout.set(false);
|
||||
self.render_ctx_watchers.clear();
|
||||
self.workspace_watchers.clear();
|
||||
|
|
@ -1478,6 +1481,31 @@ impl State {
|
|||
old: Rect,
|
||||
new: Rect,
|
||||
retained: Option<Rc<RetainedToplevel>>,
|
||||
) {
|
||||
let curve = self
|
||||
.layout_animation_curve_override
|
||||
.get()
|
||||
.unwrap_or_else(|| self.animations.curve.get());
|
||||
self.queue_layout_animation(node_id, old, new, retained, curve);
|
||||
}
|
||||
|
||||
pub fn queue_linear_layout_animation(
|
||||
self: &Rc<Self>,
|
||||
node_id: NodeId,
|
||||
old: Rect,
|
||||
new: Rect,
|
||||
retained: Option<Rc<RetainedToplevel>>,
|
||||
) {
|
||||
self.queue_layout_animation(node_id, old, new, retained, AnimationCurve::Linear);
|
||||
}
|
||||
|
||||
fn queue_layout_animation(
|
||||
self: &Rc<Self>,
|
||||
node_id: NodeId,
|
||||
old: Rect,
|
||||
new: Rect,
|
||||
retained: Option<Rc<RetainedToplevel>>,
|
||||
curve: AnimationCurve,
|
||||
) {
|
||||
if !self.animations.enabled.get()
|
||||
|| !self.layout_animations_active.get()
|
||||
|
|
@ -1506,7 +1534,7 @@ impl State {
|
|||
retained,
|
||||
now,
|
||||
self.animations.duration_ms.get(),
|
||||
self.animations.curve.get(),
|
||||
curve,
|
||||
);
|
||||
if started {
|
||||
self.damage(expand_damage_rect(
|
||||
|
|
@ -1570,6 +1598,19 @@ impl State {
|
|||
res
|
||||
}
|
||||
|
||||
pub fn with_linear_layout_animations<T>(&self, f: impl FnOnce() -> T) -> T {
|
||||
let prev_requested = self.layout_animations_requested.replace(true);
|
||||
let prev_active = self.layout_animations_active.replace(true);
|
||||
let prev_curve = self
|
||||
.layout_animation_curve_override
|
||||
.replace(Some(AnimationCurve::Linear));
|
||||
let res = f();
|
||||
self.layout_animations_requested.set(prev_requested);
|
||||
self.layout_animations_active.set(prev_active);
|
||||
self.layout_animation_curve_override.set(prev_curve);
|
||||
res
|
||||
}
|
||||
|
||||
fn ensure_animation_tick(self: &Rc<Self>) {
|
||||
if self.animations.tick_is_active() {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue