From 568fbe26fe58be7de34e46ddb980a26d12e85ac6 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 14 Apr 2024 14:29:41 +0400 Subject: Avoid continuous redrawing during horizontal gesture --- src/layout/monitor.rs | 5 ++++- src/layout/workspace.rs | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src/layout') diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 6e8cb36d..9476acfb 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -544,7 +544,10 @@ impl Monitor { pub fn are_transitions_ongoing(&self) -> bool { self.workspace_switch.is_some() - || self.workspaces.iter().any(|ws| ws.are_animations_ongoing()) + || self + .workspaces + .iter() + .any(|ws| ws.are_transitions_ongoing()) } pub fn update_config(&mut self, options: Rc) { diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 493a3c54..39e377b5 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -213,6 +213,10 @@ impl OutputId { } impl ViewOffsetAdjustment { + pub fn is_animation(&self) -> bool { + matches!(self, Self::Animation(_)) + } + pub fn target_view_offset(&self) -> f64 { match self { ViewOffsetAdjustment::Animation(anim) => anim.to(), @@ -307,6 +311,14 @@ impl Workspace { } pub fn are_animations_ongoing(&self) -> bool { + self.view_offset_adj + .as_ref() + .is_some_and(|s| s.is_animation()) + || self.columns.iter().any(Column::are_animations_ongoing) + || !self.closing_windows.is_empty() + } + + pub fn are_transitions_ongoing(&self) -> bool { self.view_offset_adj.is_some() || self.columns.iter().any(Column::are_animations_ongoing) || !self.closing_windows.is_empty() -- cgit