mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-18 06:38:38 +01:00
An animation that moves a window at one pace all the way looks flat, and the stock Geometry Change has one curve, an exponential ease out. The patched effect reads a Curve setting, the name of one of Qt's easing curves. komorebi's styles are those curves with Ease in front, so the look the backend is asked for names the curve as Qt does, and the effect's settings have it next to the duration. A cubic Bezier, which only a configuration can say, is not one of Qt's curves and is an ease out. With the stock effect every style is that ease out. komorebic gets animation-style, for every animation or the movement of windows alone. vm-features puts two curves a few seconds into a 30 s move of the same window and checks that they are in different places. The animation key of komorebi.json takes a style too, for every kind of animation or for one.
107 lines
3.8 KiB
Rust
107 lines
3.8 KiB
Rust
//! A command that changes a stack is carried out with the animation off, and the animation is on
|
|
//! again when it is done: the compositor is asked for it as it was before. The two commands that
|
|
//! ask for the look while they run, the ones that take a window out of a stack, show it.
|
|
//!
|
|
//! This file has one test because it changes the process-wide animation settings, which every
|
|
//! other test that asks for the look would see.
|
|
|
|
use komorebi::animation::ANIMATION_ENABLED_GLOBAL;
|
|
use komorebi::backend::AnimationLook;
|
|
use komorebi::backend::fake::Command;
|
|
use komorebi::backend::fake::FakeBackend;
|
|
use komorebi::backend::with_backend;
|
|
use komorebi::core::CycleDirection;
|
|
use komorebi::core::OperationDirection;
|
|
use komorebi::core::SocketMessage;
|
|
use komorebi::window::Window;
|
|
use komorebi::window_manager::WindowManager;
|
|
use komorebi::window_manager_event::KWinNotification;
|
|
use komorebi::window_manager_event::SystemNotification;
|
|
use komorebi::window_manager_event::WindowManagerEvent;
|
|
use std::sync::Arc;
|
|
use std::sync::atomic::Ordering;
|
|
|
|
#[test]
|
|
fn the_animation_is_on_again_after_a_command_that_changes_a_stack() {
|
|
let fake = Arc::new(FakeBackend::with_one_monitor());
|
|
|
|
let (_sender, receiver) = crossbeam_channel::bounded(1);
|
|
let socket =
|
|
std::path::PathBuf::from(format!("/tmp/kmb-anim-stack-{}.sock", std::process::id()));
|
|
let mut wm = with_backend(fake.clone(), || {
|
|
let mut wm = WindowManager::new(receiver, Some(socket)).unwrap();
|
|
wm.init().unwrap();
|
|
wm
|
|
});
|
|
with_backend(fake.clone(), || {
|
|
for id in 45_001..45_004 {
|
|
fake.open_window(id, "foot", "foot", &format!("terminal {id}"));
|
|
wm.process_event(WindowManagerEvent::Show(
|
|
SystemNotification::KWin(KWinNotification::WindowAdded),
|
|
Window::from(id),
|
|
))
|
|
.unwrap();
|
|
}
|
|
});
|
|
let send = |wm: &mut WindowManager, message| {
|
|
with_backend(fake.clone(), || wm.process_command(message, Vec::new())).unwrap();
|
|
};
|
|
// what the compositor was last asked to animate
|
|
let animation = || {
|
|
fake.commands()
|
|
.into_iter()
|
|
.rev()
|
|
.find_map(|command| match command {
|
|
Command::ApplyLook(look) => Some(look.animation),
|
|
_ => None,
|
|
})
|
|
.expect("the compositor was asked for a look")
|
|
};
|
|
|
|
send(&mut wm, SocketMessage::Animation(true, None));
|
|
assert_eq!(
|
|
animation(),
|
|
Some(AnimationLook {
|
|
duration_ms: 250,
|
|
curve: "Linear",
|
|
})
|
|
);
|
|
|
|
// every look the compositor is asked for while the command runs, as what it animates
|
|
let looks = || {
|
|
fake.commands()
|
|
.into_iter()
|
|
.filter_map(|command| match command {
|
|
Command::ApplyLook(look) => Some(look.animation),
|
|
_ => None,
|
|
})
|
|
.collect::<Vec<_>>()
|
|
};
|
|
let on = Some(AnimationLook {
|
|
duration_ms: 250,
|
|
curve: "Linear",
|
|
});
|
|
|
|
for (message, asked) in [
|
|
(SocketMessage::StackWindow(OperationDirection::Left), vec![]),
|
|
(SocketMessage::CycleStack(CycleDirection::Next), vec![]),
|
|
(SocketMessage::CycleStackIndex(CycleDirection::Next), vec![]),
|
|
(SocketMessage::FocusStackWindow(0), vec![]),
|
|
(SocketMessage::UnstackWindow, vec![None, on.clone()]),
|
|
(SocketMessage::StackAll, vec![]),
|
|
(SocketMessage::UnstackAll, vec![None, on.clone()]),
|
|
] {
|
|
fake.clear_commands();
|
|
send(&mut wm, message.clone());
|
|
assert!(
|
|
ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst),
|
|
"the animation is on again after {message:?}"
|
|
);
|
|
assert_eq!(
|
|
looks(),
|
|
asked,
|
|
"the compositor is asked for the look with the animation off while {message:?} runs"
|
|
);
|
|
}
|
|
}
|