1
0
Fork 0
forked from wry/wry

feat: add window animations

This commit is contained in:
atagen 2026-05-21 15:20:46 +10:00 committed by kossLAN
parent eece44a59c
commit 2a079ed800
No known key found for this signature in database
29 changed files with 6957 additions and 114 deletions

View file

@ -658,17 +658,23 @@ impl ConfigProxyHandler {
}
fn handle_seat_move(&self, seat: Seat, direction: Direction) -> Result<(), CphError> {
let seat = self.get_seat(seat)?;
seat.move_focused(direction.into());
Ok(())
self.state.with_layout_animations(|| {
let seat = self.get_seat(seat)?;
seat.move_focused(direction.into());
Ok(())
})
}
fn handle_window_move(&self, window: Window, direction: Direction) -> Result<(), CphError> {
let window = self.get_window(window)?;
if let Some(c) = toplevel_parent_container(&*window) {
c.move_child(window, direction.into());
}
Ok(())
self.state.with_layout_animations(|| {
let window = self.get_window(window)?;
if let Some(float) = window.tl_data().float.get() {
float.move_by_direction(direction.into());
} else if let Some(c) = toplevel_parent_container(&*window) {
c.move_child(window, direction.into());
}
Ok(())
})
}
fn handle_get_repeat_rate(&self, seat: Seat) -> Result<(), CphError> {
@ -986,6 +992,31 @@ impl ConfigProxyHandler {
self.state.set_ui_drag_threshold(threshold.max(1));
}
fn handle_set_animations_enabled(&self, enabled: bool) {
self.state.set_animations_enabled(enabled);
}
fn handle_set_animation_duration_ms(&self, duration_ms: u32) {
self.state
.set_animation_duration_ms(duration_ms.min(10_000));
}
fn handle_set_animation_curve(&self, curve: u32) {
self.state.set_animation_curve(curve);
}
fn handle_set_animation_style(&self, style: u32) {
if !self.state.set_animation_style(style) {
log::warn!("Ignoring invalid animation style");
}
}
fn handle_set_animation_cubic_bezier(&self, x1: f32, y1: f32, x2: f32, y2: f32) {
if !self.state.set_animation_cubic_bezier(x1, y1, x2, y2) {
log::warn!("Ignoring invalid animation cubic-bezier curve");
}
}
fn handle_set_direct_scanout_enabled(
&self,
device: Option<DrmDevice>,
@ -1732,9 +1763,11 @@ impl ConfigProxyHandler {
}
fn handle_set_seat_mono(&self, seat: Seat, mono: bool) -> Result<(), CphError> {
let seat = self.get_seat(seat)?;
seat.set_mono(mono);
Ok(())
self.state.with_layout_animations(|| {
let seat = self.get_seat(seat)?;
seat.set_mono(mono);
Ok(())
})
}
fn handle_get_window_mono(&self, window: Window) -> Result<(), CphError> {
@ -1748,11 +1781,13 @@ impl ConfigProxyHandler {
}
fn handle_set_window_mono(&self, window: Window, mono: bool) -> Result<(), CphError> {
let window = self.get_window(window)?;
if let Some(c) = toplevel_parent_container(&*window) {
c.set_mono(mono.then_some(window.as_ref()));
}
Ok(())
self.state.with_layout_animations(|| {
let window = self.get_window(window)?;
if let Some(c) = toplevel_parent_container(&*window) {
c.set_mono(mono.then_some(window.as_ref()));
}
Ok(())
})
}
fn handle_get_seat_split(&self, seat: Seat) -> Result<(), CphError> {
@ -1767,15 +1802,19 @@ impl ConfigProxyHandler {
}
fn handle_set_seat_split(&self, seat: Seat, axis: Axis) -> Result<(), CphError> {
let seat = self.get_seat(seat)?;
seat.set_split(axis.into());
Ok(())
self.state.with_layout_animations(|| {
let seat = self.get_seat(seat)?;
seat.set_split(axis.into());
Ok(())
})
}
fn handle_seat_toggle_tab(&self, seat: Seat) -> Result<(), CphError> {
let seat = self.get_seat(seat)?;
seat.toggle_tab();
Ok(())
self.state.with_layout_animations(|| {
let seat = self.get_seat(seat)?;
seat.toggle_tab();
Ok(())
})
}
fn handle_seat_make_group(
@ -1784,27 +1823,35 @@ impl ConfigProxyHandler {
axis: Axis,
ephemeral: bool,
) -> Result<(), CphError> {
let seat = self.get_seat(seat)?;
seat.make_group(axis.into(), ephemeral);
Ok(())
self.state.with_layout_animations(|| {
let seat = self.get_seat(seat)?;
seat.make_group(axis.into(), ephemeral);
Ok(())
})
}
fn handle_seat_change_group_opposite(&self, seat: Seat) -> Result<(), CphError> {
let seat = self.get_seat(seat)?;
seat.change_group_opposite();
Ok(())
self.state.with_layout_animations(|| {
let seat = self.get_seat(seat)?;
seat.change_group_opposite();
Ok(())
})
}
fn handle_seat_equalize(&self, seat: Seat, recursive: bool) -> Result<(), CphError> {
let seat = self.get_seat(seat)?;
seat.equalize(recursive);
Ok(())
self.state.with_layout_animations(|| {
let seat = self.get_seat(seat)?;
seat.equalize(recursive);
Ok(())
})
}
fn handle_seat_move_tab(&self, seat: Seat, right: bool) -> Result<(), CphError> {
let seat = self.get_seat(seat)?;
seat.move_tab(right);
Ok(())
self.state.with_layout_animations(|| {
let seat = self.get_seat(seat)?;
seat.move_tab(right);
Ok(())
})
}
fn handle_get_window_split(&self, window: Window) -> Result<(), CphError> {
@ -1819,11 +1866,13 @@ impl ConfigProxyHandler {
}
fn handle_set_window_split(&self, window: Window, axis: Axis) -> Result<(), CphError> {
let window = self.get_window(window)?;
if let Some(c) = toplevel_parent_container(&*window) {
c.set_split(axis.into());
}
Ok(())
self.state.with_layout_animations(|| {
let window = self.get_window(window)?;
if let Some(c) = toplevel_parent_container(&*window) {
c.set_split(axis.into());
}
Ok(())
})
}
fn handle_add_shortcut(
@ -1963,9 +2012,11 @@ impl ConfigProxyHandler {
}
fn handle_set_seat_floating(&self, seat: Seat, floating: bool) -> Result<(), CphError> {
let seat = self.get_seat(seat)?;
seat.set_floating(floating);
Ok(())
self.state.with_linear_layout_animations(|| {
let seat = self.get_seat(seat)?;
seat.set_floating(floating);
Ok(())
})
}
fn handle_get_window_floating(&self, window: Window) -> Result<(), CphError> {
@ -1977,9 +2028,11 @@ impl ConfigProxyHandler {
}
fn handle_set_window_floating(&self, window: Window, floating: bool) -> Result<(), CphError> {
let window = self.get_window(window)?;
toplevel_set_floating(&self.state, window, floating);
Ok(())
self.state.with_linear_layout_animations(|| {
let window = self.get_window(window)?;
toplevel_set_floating(&self.state, window, floating);
Ok(())
})
}
fn handle_add_pollable(self: &Rc<Self>, fd: i32) -> Result<(), CphError> {
@ -2729,8 +2782,10 @@ impl ConfigProxyHandler {
dx2: i32,
dy2: i32,
) -> Result<(), CphError> {
self.get_window(window)?.tl_resize(dx1, dy1, dx2, dy2);
Ok(())
self.state.with_layout_animations(|| {
self.get_window(window)?.tl_resize(dx1, dy1, dx2, dy2);
Ok(())
})
}
fn handle_window_exists(&self, window: Window) {
@ -3207,6 +3262,17 @@ impl ConfigProxyHandler {
ClientMessage::SetUiDragThreshold { threshold } => {
self.handle_set_ui_drag_threshold(threshold)
}
ClientMessage::SetAnimationsEnabled { enabled } => {
self.handle_set_animations_enabled(enabled)
}
ClientMessage::SetAnimationDurationMs { duration_ms } => {
self.handle_set_animation_duration_ms(duration_ms)
}
ClientMessage::SetAnimationCurve { curve } => self.handle_set_animation_curve(curve),
ClientMessage::SetAnimationStyle { style } => self.handle_set_animation_style(style),
ClientMessage::SetAnimationCubicBezier { x1, y1, x2, y2 } => {
self.handle_set_animation_cubic_bezier(x1, y1, x2, y2)
}
ClientMessage::SetXScalingMode { mode } => self
.handle_set_x_scaling_mode(mode)
.wrn("set_x_scaling_mode")?,