fix(animation): disable on cross-monitor ops

There are quite a lot of janky animation bugs when moving window
containers across monitor and workspace boundaries.

This commit disables animation on all of the main cross-border window
container operations, meaning that animations should now only happen
within the context of a single workspace.

fix #912
This commit is contained in:
LGUG2Z
2024-07-11 20:51:40 -07:00
parent 2c8f25ef82
commit 50a279239a
3 changed files with 32 additions and 4 deletions

View File

@@ -228,6 +228,7 @@ pub static SESSION_ID: AtomicU32 = AtomicU32::new(0);
pub static REMOVE_TITLEBARS: AtomicBool = AtomicBool::new(false);
pub static ANIMATION_ENABLED: AtomicBool = AtomicBool::new(false);
pub static ANIMATION_TEMPORARY_DISABLED: AtomicBool = AtomicBool::new(false);
pub static ANIMATION_DURATION: AtomicU64 = AtomicU64::new(250);
#[must_use]

View File

@@ -5,6 +5,7 @@ use crate::stackbar_manager;
use crate::ANIMATIONS_IN_PROGRESS;
use crate::ANIMATION_DURATION;
use crate::ANIMATION_ENABLED;
use crate::ANIMATION_TEMPORARY_DISABLED;
use std::collections::HashMap;
use std::convert::TryFrom;
use std::fmt::Display;
@@ -223,7 +224,9 @@ impl Window {
return Ok(());
}
if ANIMATION_ENABLED.load(Ordering::SeqCst) {
if ANIMATION_ENABLED.load(Ordering::SeqCst)
&& !ANIMATION_TEMPORARY_DISABLED.load(Ordering::SeqCst)
{
self.animate_position(layout, top)
} else {
WindowsApi::position_window(self.hwnd(), layout, top)

View File

@@ -65,6 +65,7 @@ use crate::BorderColours;
use crate::Colour;
use crate::Rgb;
use crate::WorkspaceRule;
use crate::ANIMATION_TEMPORARY_DISABLED;
use crate::CUSTOM_FFM;
use crate::DATA_DIR;
use crate::DISPLAY_INDEX_PREFERENCES;
@@ -1108,6 +1109,7 @@ impl WindowManager {
follow: bool,
) -> Result<()> {
self.handle_unmanaged_window_behaviour()?;
ANIMATION_TEMPORARY_DISABLED.store(true, Ordering::SeqCst);
tracing::info!("moving container");
@@ -1177,12 +1179,17 @@ impl WindowManager {
self.focus_monitor(monitor_idx)?;
}
self.update_focused_workspace(self.mouse_follows_focus, true)
self.update_focused_workspace(self.mouse_follows_focus, true)?;
ANIMATION_TEMPORARY_DISABLED.store(false, Ordering::SeqCst);
Ok(())
}
#[tracing::instrument(skip(self))]
pub fn move_container_to_workspace(&mut self, idx: usize, follow: bool) -> Result<()> {
self.handle_unmanaged_window_behaviour()?;
ANIMATION_TEMPORARY_DISABLED.store(true, Ordering::SeqCst);
tracing::info!("moving container");
@@ -1194,7 +1201,11 @@ impl WindowManager {
monitor.move_container_to_workspace(idx, follow)?;
monitor.load_focused_workspace(mouse_follows_focus)?;
self.update_focused_workspace(mouse_follows_focus, true)
self.update_focused_workspace(mouse_follows_focus, true)?;
ANIMATION_TEMPORARY_DISABLED.store(false, Ordering::SeqCst);
Ok(())
}
pub fn remove_focused_workspace(&mut self) -> Option<Workspace> {
@@ -1297,6 +1308,13 @@ impl WindowManager {
let origin_monitor_idx = self.focused_monitor_idx();
let target_container_idx = workspace.new_idx_for_direction(direction);
let animation_temporarily_disabled = if target_container_idx.is_none() {
ANIMATION_TEMPORARY_DISABLED.store(true, Ordering::SeqCst);
true
} else {
false
};
match target_container_idx {
// If there is nowhere to move on the current workspace, try to move it onto the monitor
// in that direction if there is one
@@ -1421,7 +1439,13 @@ impl WindowManager {
}
}
self.update_focused_workspace(self.mouse_follows_focus, true)
self.update_focused_workspace(self.mouse_follows_focus, true)?;
if animation_temporarily_disabled {
ANIMATION_TEMPORARY_DISABLED.store(false, Ordering::SeqCst);
}
Ok(())
}
#[tracing::instrument(skip(self))]