From a368285209c0c312b75e6827cbf95449b36b62d2 Mon Sep 17 00:00:00 2001 From: lars-berger Date: Sun, 29 Sep 2024 14:20:41 +0800 Subject: [PATCH] fix: cursor jump to correct target monitor (#744) --- packages/wm/src/common/commands/platform_sync.rs | 3 ++- packages/wm/src/common/vec_deque_ext.rs | 10 ---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/wm/src/common/commands/platform_sync.rs b/packages/wm/src/common/commands/platform_sync.rs index dceb2f70e..d56f0a77d 100644 --- a/packages/wm/src/common/commands/platform_sync.rs +++ b/packages/wm/src/common/commands/platform_sync.rs @@ -149,9 +149,10 @@ fn jump_cursor( let cursor_monitor = state.monitor_at_position(&Platform::mouse_position()?); + // Jump to the target monitor if the cursor is not already on it. cursor_monitor .filter(|monitor| monitor.id() != target_monitor.id()) - .map(Into::into) + .map(|_| target_monitor.into()) } }; diff --git a/packages/wm/src/common/vec_deque_ext.rs b/packages/wm/src/common/vec_deque_ext.rs index cc370d261..ddb82f5f5 100644 --- a/packages/wm/src/common/vec_deque_ext.rs +++ b/packages/wm/src/common/vec_deque_ext.rs @@ -8,10 +8,6 @@ where /// /// Inserts at index if value doesn't already exist in the `VecDeque`. fn shift_to_index(&mut self, target_index: usize, item: T); - - /// Replaces the first occurrence of a value with a new value in a - /// `VecDeque`. - fn replace(&mut self, old_value: &T, new_value: T); } impl VecDequeExt for VecDeque @@ -27,10 +23,4 @@ where self.insert(target_index.clamp(0, self.len()), value); } } - - fn replace(&mut self, old_value: &T, new_value: T) { - if let Some(index) = self.iter().position(|e| e == old_value) { - self[index] = new_value; - } - } }