mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-18 22:58:34 +01:00
refactor(windows): move the animation settings to settings
Plan step 10, S5 for Windows. The six ANIMATION_* statics (global enabled, style, duration; per-kind enabled, style, duration) and ANIMATION_FPS are gone (ANIMATION_MANAGER and GHOST_MOVEMENT_ENABLED stay: runtime state and a Windows-only setting). The Animation, AnimationDuration, AnimationFps and AnimationStyle commands each write settings().shared.animation with one update; the animation block of a load is one update through SharedDelta::apply (a global value clears that setting's per-kind map, a map replaces it, a block without fps has the default, no block keeps all); shutdown (daemon.rs, window_manager.rs) is animation_off_for_good(), one update that clears the per-kind map and turns the global flag off. Readers keep Windows' own rules, which are NOT the KDE and macOS ones: a kind is animated when the global flag is on OR its per-kind value is true (a per-kind false does not turn off a global true), and the workspace transition helpers keep their per-kind-wins rule; the accessors in settings.rs (animation_enabled_for, animation_for) encode the first and the existing transitions_enabled_by / duration_for / style_for are fed from one snapshot. Window::move/transparent/opaque and the maximize wait read enabled, duration and style from one snapshot, and no longer hold the per-kind map's lock for the rest of the function. BEHAVIOUR: no thread can see half an animation reload; one publish per load or command. Gate: Windows e2e (animation, config_reload, lifecycle for the shutdown path, commands). Verified: Windows clippy -D warnings --locked --all-targets on komorebi-windows (cross): clean. e2e not run.
This commit is contained in:
1 parent
d6c0c6f115
commit
482c42d64f
10 files changed
+153
-190
No files matched your search
@@ -3,12 +3,9 @@ use color_eyre::eyre;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::cell::RefCell;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
|
||||
use super::ANIMATION_DURATION_GLOBAL;
|
||||
use super::ANIMATION_FPS;
|
||||
use super::ANIMATION_MANAGER;
|
||||
use super::RenderDispatcher;
|
||||
|
||||
@@ -32,7 +29,7 @@ impl AnimationEngine {
|
||||
}
|
||||
|
||||
std::thread::sleep(Duration::from_millis(
|
||||
ANIMATION_DURATION_GLOBAL.load(Ordering::SeqCst),
|
||||
crate::settings::animation_duration_global(),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -135,7 +132,7 @@ impl AnimationEngine {
|
||||
}
|
||||
|
||||
let target_frame_time =
|
||||
Duration::from_millis(1000 / ANIMATION_FPS.load(Ordering::Relaxed));
|
||||
Duration::from_millis(1000 / crate::settings::animation_fps());
|
||||
let animation_start = Instant::now();
|
||||
|
||||
let mut stats = FrameStats::default();
|
||||
|
||||
@@ -6,7 +6,6 @@ use prefix::AnimationPrefix;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::AtomicU64;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -35,18 +34,6 @@ pub const DEFAULT_GHOST_MOVEMENT: bool = false;
|
||||
lazy_static! {
|
||||
pub static ref ANIMATION_MANAGER: Arc<Mutex<AnimationManager>> =
|
||||
Arc::new(Mutex::new(AnimationManager::new()));
|
||||
pub static ref ANIMATION_STYLE_GLOBAL: Arc<Mutex<AnimationStyle>> =
|
||||
Arc::new(Mutex::new(DEFAULT_ANIMATION_STYLE));
|
||||
pub static ref ANIMATION_ENABLED_GLOBAL: Arc<AtomicBool> =
|
||||
Arc::new(AtomicBool::new(DEFAULT_ANIMATION_ENABLED));
|
||||
pub static ref ANIMATION_DURATION_GLOBAL: Arc<AtomicU64> =
|
||||
Arc::new(AtomicU64::new(DEFAULT_ANIMATION_DURATION));
|
||||
pub static ref ANIMATION_STYLE_PER_ANIMATION: Arc<Mutex<HashMap<AnimationPrefix, AnimationStyle>>> =
|
||||
Arc::new(Mutex::new(HashMap::new()));
|
||||
pub static ref ANIMATION_ENABLED_PER_ANIMATION: Arc<Mutex<HashMap<AnimationPrefix, bool>>> =
|
||||
Arc::new(Mutex::new(HashMap::new()));
|
||||
pub static ref ANIMATION_DURATION_PER_ANIMATION: Arc<Mutex<HashMap<AnimationPrefix, u64>>> =
|
||||
Arc::new(Mutex::new(HashMap::new()));
|
||||
}
|
||||
|
||||
/// Whether the windows of a workspace slide out of a monitor and those of the
|
||||
@@ -87,32 +74,40 @@ fn style_for(
|
||||
|
||||
/// Whether workspaces slide in and out of the monitor when they are switched
|
||||
pub fn workspace_transitions_enabled() -> bool {
|
||||
let snapshot = crate::settings::settings().snapshot();
|
||||
let animation = &snapshot.shared.animation;
|
||||
|
||||
transitions_enabled_by(
|
||||
GHOST_MOVEMENT_ENABLED.load(Ordering::Relaxed),
|
||||
ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst),
|
||||
&ANIMATION_ENABLED_PER_ANIMATION.lock(),
|
||||
animation.enabled,
|
||||
&animation.enabled_per_animation,
|
||||
)
|
||||
}
|
||||
|
||||
/// How long a workspace takes to slide in and out of a monitor
|
||||
pub fn workspace_transition_duration() -> Duration {
|
||||
let snapshot = crate::settings::settings().snapshot();
|
||||
let animation = &snapshot.shared.animation;
|
||||
|
||||
duration_for(
|
||||
AnimationPrefix::Workspace,
|
||||
&ANIMATION_DURATION_PER_ANIMATION.lock(),
|
||||
ANIMATION_DURATION_GLOBAL.load(Ordering::SeqCst),
|
||||
&animation.duration_per_animation,
|
||||
animation.duration,
|
||||
)
|
||||
}
|
||||
|
||||
/// How a workspace eases as it slides in and out of a monitor
|
||||
pub fn workspace_transition_style() -> AnimationStyle {
|
||||
let snapshot = crate::settings::settings().snapshot();
|
||||
let animation = &snapshot.shared.animation;
|
||||
|
||||
style_for(
|
||||
AnimationPrefix::Workspace,
|
||||
&ANIMATION_STYLE_PER_ANIMATION.lock(),
|
||||
*ANIMATION_STYLE_GLOBAL.lock(),
|
||||
&animation.style_per_animation,
|
||||
animation.style,
|
||||
)
|
||||
}
|
||||
|
||||
pub static ANIMATION_FPS: AtomicU64 = AtomicU64::new(DEFAULT_ANIMATION_FPS);
|
||||
pub static GHOST_MOVEMENT_ENABLED: AtomicBool = AtomicBool::new(DEFAULT_GHOST_MOVEMENT);
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -20,8 +20,6 @@ use clap::ValueEnum;
|
||||
use color_eyre::eyre;
|
||||
use color_eyre::eyre::bail;
|
||||
use crossbeam_utils::Backoff;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::AnimationEngine;
|
||||
use crate::replace_env_in_path;
|
||||
use parking_lot::Mutex;
|
||||
@@ -364,8 +362,7 @@ pub fn run() -> eyre::Result<()> {
|
||||
let state = State::from(&*wm.lock());
|
||||
std::fs::write(dumped_state, serde_json::to_string_pretty(&state)?)?;
|
||||
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
|
||||
ANIMATION_ENABLED_GLOBAL.store(false, Ordering::SeqCst);
|
||||
crate::settings::animation_off_for_good();
|
||||
wm.lock().restore_all_windows(false)?;
|
||||
AnimationEngine::wait_for_all_animations();
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
//! it began puts the neighbours back.
|
||||
|
||||
use crate::WindowsApi;
|
||||
use crate::animation::ANIMATION_DURATION_GLOBAL;
|
||||
use crate::animation::GHOST_MOVEMENT_ENABLED;
|
||||
use crate::animation::ghost::GhostWindow;
|
||||
use crate::animation::ghost::is_swap_chain_window;
|
||||
@@ -368,7 +367,7 @@ fn glide_frame(from: &Rect, to: &Rect, progress: f64) -> Rect {
|
||||
/// long as an animation takes, and nothing else is done until they are there. For the windows
|
||||
/// of a strip that is let go of, which then does not jump to where it comes to rest.
|
||||
pub fn glide() {
|
||||
let duration = Duration::from_millis(ANIMATION_DURATION_GLOBAL.load(Ordering::SeqCst));
|
||||
let duration = Duration::from_millis(crate::settings::animation_duration_global());
|
||||
|
||||
let mut covers = COVERS.lock();
|
||||
let Some(covers) = covers.as_mut() else {
|
||||
|
||||
@@ -47,13 +47,6 @@ use crate::TCP_CONNECTIONS;
|
||||
use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS;
|
||||
use crate::WINDOWS_11;
|
||||
use crate::WORKSPACE_MATCHING_RULES;
|
||||
use crate::animation::ANIMATION_DURATION_GLOBAL;
|
||||
use crate::animation::ANIMATION_DURATION_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_FPS;
|
||||
use crate::animation::ANIMATION_STYLE_GLOBAL;
|
||||
use crate::animation::ANIMATION_STYLE_PER_ANIMATION;
|
||||
use crate::border_manager;
|
||||
use crate::border_manager::IMPLEMENTATION;
|
||||
use crate::border_manager::STYLE;
|
||||
@@ -1399,41 +1392,51 @@ impl WindowManager {
|
||||
border_manager::BORDER_OFFSET.store(offset, Ordering::SeqCst);
|
||||
force_update_borders = true;
|
||||
}
|
||||
SocketMessage::Animation(enable, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_ENABLED_PER_ANIMATION
|
||||
.lock()
|
||||
.insert(prefix, enable);
|
||||
}
|
||||
None => {
|
||||
ANIMATION_ENABLED_GLOBAL.store(enable, Ordering::SeqCst);
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
SocketMessage::AnimationDuration(duration, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_DURATION_PER_ANIMATION
|
||||
.lock()
|
||||
.insert(prefix, duration);
|
||||
}
|
||||
None => {
|
||||
ANIMATION_DURATION_GLOBAL.store(duration, Ordering::SeqCst);
|
||||
ANIMATION_DURATION_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
SocketMessage::AnimationFps(fps) => {
|
||||
ANIMATION_FPS.store(fps, Ordering::SeqCst);
|
||||
SocketMessage::Animation(enable, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.enabled_per_animation.insert(prefix, enable);
|
||||
}
|
||||
None => {
|
||||
animation.enabled = enable;
|
||||
animation.enabled_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationDuration(duration, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.duration_per_animation.insert(prefix, duration);
|
||||
}
|
||||
None => {
|
||||
animation.duration = duration;
|
||||
animation.duration_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationFps(fps) => {
|
||||
crate::settings::settings().update(|settings| settings.shared.animation.fps = fps);
|
||||
}
|
||||
SocketMessage::AnimationStyle(style, prefix) => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
let animation = &mut settings.shared.animation;
|
||||
match prefix {
|
||||
Some(prefix) => {
|
||||
animation.style_per_animation.insert(prefix, style);
|
||||
}
|
||||
None => {
|
||||
animation.style = style;
|
||||
animation.style_per_animation.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
SocketMessage::AnimationStyle(style, prefix) => match prefix {
|
||||
Some(prefix) => {
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().insert(prefix, style);
|
||||
}
|
||||
None => {
|
||||
let mut animation_style = ANIMATION_STYLE_GLOBAL.lock();
|
||||
*animation_style = style;
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
},
|
||||
SocketMessage::ToggleTransparency => {
|
||||
crate::settings::settings().update(|settings| {
|
||||
settings.shared.transparency.enabled = !settings.shared.transparency.enabled;
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
//! [`Workspace`]: a container is a tile in the strip, and is known to it by its id.
|
||||
|
||||
use crate::WINDOW_HANDLING_BEHAVIOUR;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_MANAGER;
|
||||
use crate::animation::prefix::AnimationPrefix;
|
||||
use crate::container::Container;
|
||||
@@ -26,7 +24,6 @@ use komorebi_scrolling::ColumnWidth;
|
||||
use komorebi_scrolling::Options;
|
||||
use komorebi_scrolling::ScrollingSpace;
|
||||
use komorebi_scrolling::Visibility;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
/// What the layout options of a workspace come to for the model.
|
||||
pub(crate) fn scrolling_options(layout_options: Option<LayoutOptions>) -> Options {
|
||||
@@ -159,11 +156,7 @@ pub(crate) fn should_restore_when_placed(
|
||||
|
||||
/// Whether windows that are moved are animated to where they go.
|
||||
pub(crate) fn animations_enabled() -> bool {
|
||||
ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst)
|
||||
|| ANIMATION_ENABLED_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&AnimationPrefix::Movement)
|
||||
.is_some_and(|enabled| *enabled)
|
||||
crate::settings::animation_enabled_for(AnimationPrefix::Movement)
|
||||
}
|
||||
|
||||
pub(crate) trait WorkspaceScrolling {
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::LazyLock;
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::animation::prefix::AnimationPrefix;
|
||||
use crate::core::animation::AnimationStyle;
|
||||
|
||||
use komorebi_config::aspect_ratio::AspectRatio;
|
||||
use komorebi_layouts::DefaultLayout;
|
||||
@@ -77,6 +81,69 @@ pub fn transparency_alpha() -> u8 {
|
||||
settings().snapshot().shared.transparency.alpha
|
||||
}
|
||||
|
||||
// The animation settings. Windows decides whether a kind of animation is on as: the global flag, or
|
||||
// a per-kind value of true (a per-kind false does NOT turn off a global true, unlike KDE and macOS).
|
||||
|
||||
/// Whether `prefix` is animated: the global flag, or a per-kind true.
|
||||
pub fn animation_enabled_for(prefix: AnimationPrefix) -> bool {
|
||||
let snapshot = settings().snapshot();
|
||||
let animation = &snapshot.shared.animation;
|
||||
|
||||
animation.enabled
|
||||
|| animation
|
||||
.enabled_per_animation
|
||||
.get(&prefix)
|
||||
.is_some_and(|enabled| *enabled)
|
||||
}
|
||||
|
||||
/// How `prefix` is animated, from one snapshot, or `None` if it is not (see [`animation_enabled_for`]).
|
||||
pub fn animation_for(prefix: AnimationPrefix) -> Option<(Duration, AnimationStyle)> {
|
||||
let snapshot = settings().snapshot();
|
||||
let animation = &snapshot.shared.animation;
|
||||
|
||||
let enabled = animation.enabled
|
||||
|| animation
|
||||
.enabled_per_animation
|
||||
.get(&prefix)
|
||||
.is_some_and(|enabled| *enabled);
|
||||
|
||||
enabled.then(|| {
|
||||
(
|
||||
Duration::from_millis(
|
||||
animation
|
||||
.duration_per_animation
|
||||
.get(&prefix)
|
||||
.copied()
|
||||
.unwrap_or(animation.duration),
|
||||
),
|
||||
animation
|
||||
.style_per_animation
|
||||
.get(&prefix)
|
||||
.copied()
|
||||
.unwrap_or(animation.style),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// `animation.fps`.
|
||||
pub fn animation_fps() -> u64 {
|
||||
settings().snapshot().shared.animation.fps
|
||||
}
|
||||
|
||||
/// The global `animation.duration`, in milliseconds.
|
||||
pub fn animation_duration_global() -> u64 {
|
||||
settings().snapshot().shared.animation.duration
|
||||
}
|
||||
|
||||
/// Turns every animation off for good (the global flag and the per-kind values): what shutdown does
|
||||
/// before it puts the windows back.
|
||||
pub fn animation_off_for_good() {
|
||||
settings().update(|settings| {
|
||||
settings.shared.animation.enabled_per_animation.clear();
|
||||
settings.shared.animation.enabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
@@ -21,17 +21,8 @@ use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS;
|
||||
use crate::WINDOW_HANDLING_BEHAVIOUR;
|
||||
use crate::WINDOWS_11;
|
||||
use crate::WORKSPACE_MATCHING_RULES;
|
||||
use crate::animation::ANIMATION_DURATION_GLOBAL;
|
||||
use crate::animation::ANIMATION_DURATION_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_FPS;
|
||||
use crate::animation::ANIMATION_STYLE_GLOBAL;
|
||||
use crate::animation::ANIMATION_STYLE_PER_ANIMATION;
|
||||
use crate::animation::DEFAULT_ANIMATION_FPS;
|
||||
use crate::animation::DEFAULT_GHOST_MOVEMENT;
|
||||
use crate::animation::GHOST_MOVEMENT_ENABLED;
|
||||
use crate::animation::PerAnimationPrefixConfig;
|
||||
use crate::asc::ApplicationSpecificConfiguration;
|
||||
use crate::asc::AscApplicationRulesOrSchema;
|
||||
use crate::border_manager;
|
||||
@@ -78,6 +69,7 @@ use color_eyre::eyre;
|
||||
use crossbeam_channel::Receiver;
|
||||
use hotwatch::EventKind;
|
||||
use hotwatch::Hotwatch;
|
||||
use komorebi_settings::shared::AnimationDelta;
|
||||
use komorebi_settings::shared::SharedDelta;
|
||||
use komorebi_themes::colour::Colour;
|
||||
use parking_lot::Mutex;
|
||||
@@ -425,43 +417,20 @@ impl ApplyGlobals for StaticConfig {
|
||||
}
|
||||
|
||||
if let Some(animations) = &self.animation {
|
||||
match &animations.enabled {
|
||||
PerAnimationPrefixConfig::Prefix(enabled) => {
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clone_from(enabled);
|
||||
// enabled, style, duration and fps as one update: a global value clears its per-animation
|
||||
// map, a map replaces the map, a block without `fps` has the default (`SharedDelta::apply`)
|
||||
crate::settings::settings().update(|settings| {
|
||||
SharedDelta {
|
||||
animation: Some(AnimationDelta {
|
||||
enabled: animations.enabled.clone(),
|
||||
style: animations.style.clone(),
|
||||
duration: animations.duration.clone(),
|
||||
fps: animations.fps,
|
||||
}),
|
||||
..SharedDelta::default()
|
||||
}
|
||||
PerAnimationPrefixConfig::Global(enabled) => {
|
||||
ANIMATION_ENABLED_GLOBAL.store(*enabled, Ordering::SeqCst);
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
}
|
||||
|
||||
match &animations.style {
|
||||
Some(PerAnimationPrefixConfig::Prefix(style)) => {
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().clone_from(style);
|
||||
}
|
||||
Some(PerAnimationPrefixConfig::Global(style)) => {
|
||||
let mut animation_style = ANIMATION_STYLE_GLOBAL.lock();
|
||||
*animation_style = *style;
|
||||
ANIMATION_STYLE_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
match &animations.duration {
|
||||
Some(PerAnimationPrefixConfig::Prefix(duration)) => {
|
||||
ANIMATION_DURATION_PER_ANIMATION.lock().clone_from(duration);
|
||||
}
|
||||
Some(PerAnimationPrefixConfig::Global(duration)) => {
|
||||
ANIMATION_DURATION_GLOBAL.store(*duration, Ordering::SeqCst);
|
||||
ANIMATION_DURATION_PER_ANIMATION.lock().clear();
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
ANIMATION_FPS.store(
|
||||
animations.fps.unwrap_or(DEFAULT_ANIMATION_FPS),
|
||||
Ordering::SeqCst,
|
||||
);
|
||||
.apply(&mut settings.shared);
|
||||
});
|
||||
|
||||
let ghost_movement_enabled =
|
||||
animations.ghost_movement.unwrap_or(DEFAULT_GHOST_MOVEMENT);
|
||||
|
||||
+7
-61
@@ -11,13 +11,7 @@ use crate::REGEX_IDENTIFIERS;
|
||||
use crate::SLOW_APPLICATION_COMPENSATION_TIME;
|
||||
use crate::SLOW_APPLICATION_IDENTIFIERS;
|
||||
use crate::WSL2_UI_PROCESSES;
|
||||
use crate::animation::ANIMATION_DURATION_GLOBAL;
|
||||
use crate::animation::ANIMATION_DURATION_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::ANIMATION_MANAGER;
|
||||
use crate::animation::ANIMATION_STYLE_GLOBAL;
|
||||
use crate::animation::ANIMATION_STYLE_PER_ANIMATION;
|
||||
use crate::animation::AnimationEngine;
|
||||
use crate::animation::RenderDispatcher;
|
||||
use crate::animation::ghost_dispatcher::GhostDispatcher;
|
||||
@@ -273,13 +267,7 @@ impl Window {
|
||||
let is_maximized = &new_rect == target_area;
|
||||
if is_maximized {
|
||||
windows_api::WindowsApi::unmaximize_window(self.hwnd);
|
||||
let animation_enabled = ANIMATION_ENABLED_PER_ANIMATION.lock();
|
||||
let move_enabled = animation_enabled
|
||||
.get(&GhostDispatcher::PREFIX)
|
||||
.is_some_and(|v| *v);
|
||||
drop(animation_enabled);
|
||||
|
||||
if move_enabled || ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst) {
|
||||
if crate::settings::animation_enabled_for(GhostDispatcher::PREFIX) {
|
||||
let anim_count = ANIMATION_MANAGER
|
||||
.lock()
|
||||
.count_in_progress(GhostDispatcher::PREFIX);
|
||||
@@ -414,22 +402,8 @@ impl Window {
|
||||
return WindowsApi::position_window(self.hwnd, layout, top, true);
|
||||
}
|
||||
|
||||
let animation_enabled = ANIMATION_ENABLED_PER_ANIMATION.lock();
|
||||
let move_enabled = animation_enabled.get(&GhostDispatcher::PREFIX);
|
||||
|
||||
if move_enabled.is_some_and(|enabled| *enabled)
|
||||
|| ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst)
|
||||
{
|
||||
let duration = Duration::from_millis(
|
||||
*ANIMATION_DURATION_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&GhostDispatcher::PREFIX)
|
||||
.unwrap_or(&ANIMATION_DURATION_GLOBAL.load(Ordering::SeqCst)),
|
||||
);
|
||||
let style = *ANIMATION_STYLE_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&GhostDispatcher::PREFIX)
|
||||
.unwrap_or(&ANIMATION_STYLE_GLOBAL.lock());
|
||||
// enabled, duration and style from one snapshot
|
||||
if let Some((duration, style)) = crate::settings::animation_for(GhostDispatcher::PREFIX) {
|
||||
|
||||
let render_dispatcher =
|
||||
GhostDispatcher::new(self.hwnd, window_rect, *layout, top, style);
|
||||
@@ -610,22 +584,8 @@ impl Window {
|
||||
}
|
||||
|
||||
pub fn transparent(self) -> eyre::Result<()> {
|
||||
let animation_enabled = ANIMATION_ENABLED_PER_ANIMATION.lock();
|
||||
let transparent_enabled = animation_enabled.get(&TransparencyRenderDispatcher::PREFIX);
|
||||
|
||||
if transparent_enabled.is_some_and(|enabled| *enabled)
|
||||
|| ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst)
|
||||
{
|
||||
let duration = Duration::from_millis(
|
||||
*ANIMATION_DURATION_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&TransparencyRenderDispatcher::PREFIX)
|
||||
.unwrap_or(&ANIMATION_DURATION_GLOBAL.load(Ordering::SeqCst)),
|
||||
);
|
||||
let style = *ANIMATION_STYLE_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&TransparencyRenderDispatcher::PREFIX)
|
||||
.unwrap_or(&ANIMATION_STYLE_GLOBAL.lock());
|
||||
// enabled, duration and style from one snapshot
|
||||
if let Some((duration, style)) = crate::settings::animation_for(TransparencyRenderDispatcher::PREFIX) {
|
||||
|
||||
let render_dispatcher = TransparencyRenderDispatcher::new(
|
||||
self.hwnd,
|
||||
@@ -648,22 +608,8 @@ impl Window {
|
||||
}
|
||||
|
||||
pub fn opaque(self) -> eyre::Result<()> {
|
||||
let animation_enabled = ANIMATION_ENABLED_PER_ANIMATION.lock();
|
||||
let transparent_enabled = animation_enabled.get(&TransparencyRenderDispatcher::PREFIX);
|
||||
|
||||
if transparent_enabled.is_some_and(|enabled| *enabled)
|
||||
|| ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst)
|
||||
{
|
||||
let duration = Duration::from_millis(
|
||||
*ANIMATION_DURATION_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&TransparencyRenderDispatcher::PREFIX)
|
||||
.unwrap_or(&ANIMATION_DURATION_GLOBAL.load(Ordering::SeqCst)),
|
||||
);
|
||||
let style = *ANIMATION_STYLE_PER_ANIMATION
|
||||
.lock()
|
||||
.get(&TransparencyRenderDispatcher::PREFIX)
|
||||
.unwrap_or(&ANIMATION_STYLE_GLOBAL.lock());
|
||||
// enabled, duration and style from one snapshot
|
||||
if let Some((duration, style)) = crate::settings::animation_for(TransparencyRenderDispatcher::PREFIX) {
|
||||
|
||||
let render_dispatcher = TransparencyRenderDispatcher::new(
|
||||
self.hwnd,
|
||||
|
||||
@@ -26,8 +26,6 @@ use uds_windows::UnixStream;
|
||||
|
||||
use crate::HIDING_BEHAVIOUR;
|
||||
use crate::HidingBehaviour;
|
||||
use crate::animation::ANIMATION_ENABLED_GLOBAL;
|
||||
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
|
||||
use crate::animation::AnimationEngine;
|
||||
use crate::animation::engine::AnimationBatch;
|
||||
use crate::animation::transition;
|
||||
@@ -1452,8 +1450,7 @@ impl WindowManager {
|
||||
serde_json::to_string_pretty(&state)?,
|
||||
)?;
|
||||
|
||||
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
|
||||
ANIMATION_ENABLED_GLOBAL.store(false, Ordering::SeqCst);
|
||||
crate::settings::animation_off_for_good();
|
||||
self.restore_all_windows(ignore_restore)?;
|
||||
AnimationEngine::wait_for_all_animations();
|
||||
|
||||
|
||||
Reference in new issue
Block a user