mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-25 10:08:33 +02:00
fix(animation): added pending cancel count to track is_cancelled state
This commit is contained in:
@@ -440,6 +440,8 @@ impl Animation {
|
|||||||
|
|
||||||
let latest_cancel_idx = ANIMATION_MANAGER.lock().latest_cancel_idx(self.hwnd);
|
let latest_cancel_idx = ANIMATION_MANAGER.lock().latest_cancel_idx(self.hwnd);
|
||||||
|
|
||||||
|
ANIMATION_MANAGER.lock().end_cancel(self.hwnd);
|
||||||
|
|
||||||
latest_cancel_idx == cancel_idx
|
latest_cancel_idx == cancel_idx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ pub static ANIMATIONS_IN_PROGRESS: AtomicUsize = AtomicUsize::new(0);
|
|||||||
struct AnimationState {
|
struct AnimationState {
|
||||||
pub in_progress: bool,
|
pub in_progress: bool,
|
||||||
pub cancel_idx_counter: usize,
|
pub cancel_idx_counter: usize,
|
||||||
|
pub pending_cancel_count: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -31,7 +32,7 @@ impl AnimationManager {
|
|||||||
|
|
||||||
pub fn is_cancelled(&self, hwnd: isize) -> bool {
|
pub fn is_cancelled(&self, hwnd: isize) -> bool {
|
||||||
if let Some(animation_state) = self.animations.get(&hwnd) {
|
if let Some(animation_state) = self.animations.get(&hwnd) {
|
||||||
animation_state.cancel_idx_counter > 0
|
animation_state.pending_cancel_count > 0
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@@ -47,7 +48,10 @@ impl AnimationManager {
|
|||||||
|
|
||||||
pub fn init_cancel(&mut self, hwnd: isize) -> usize {
|
pub fn init_cancel(&mut self, hwnd: isize) -> usize {
|
||||||
if let Some(animation_state) = self.animations.get_mut(&hwnd) {
|
if let Some(animation_state) = self.animations.get_mut(&hwnd) {
|
||||||
|
animation_state.pending_cancel_count += 1;
|
||||||
animation_state.cancel_idx_counter += 1;
|
animation_state.cancel_idx_counter += 1;
|
||||||
|
|
||||||
|
// return cancel idx
|
||||||
animation_state.cancel_idx_counter
|
animation_state.cancel_idx_counter
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
@@ -62,6 +66,12 @@ impl AnimationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn end_cancel(&mut self, hwnd: isize) {
|
||||||
|
if let Some(animation_state) = self.animations.get_mut(&hwnd) {
|
||||||
|
animation_state.pending_cancel_count -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn cancel(&mut self, hwnd: isize) {
|
pub fn cancel(&mut self, hwnd: isize) {
|
||||||
if let Some(animation_state) = self.animations.get_mut(&hwnd) {
|
if let Some(animation_state) = self.animations.get_mut(&hwnd) {
|
||||||
animation_state.in_progress = false;
|
animation_state.in_progress = false;
|
||||||
@@ -73,6 +83,7 @@ impl AnimationManager {
|
|||||||
e.insert(AnimationState {
|
e.insert(AnimationState {
|
||||||
in_progress: true,
|
in_progress: true,
|
||||||
cancel_idx_counter: 0,
|
cancel_idx_counter: 0,
|
||||||
|
pending_cancel_count: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
ANIMATIONS_IN_PROGRESS.store(self.animations.len(), Ordering::Release);
|
ANIMATIONS_IN_PROGRESS.store(self.animations.len(), Ordering::Release);
|
||||||
|
|||||||
Reference in New Issue
Block a user