A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.
Rust archive-managerdesktop-appdual-paneexplorer-alternativefile-browserfile-explorerfile-managerfluent-designgpu-acceleratedgpuimacosmicaproductivityquick-lookrustrust-guitabswindowswindows-11windows-explorer
Alt+Tab: a pointer that only trembles no longer takes the selection from the keys
gelenmedya5372b4aa986f
diff --git a/crates/rf-app/src/shell/switcher/view.rs b/crates/rf-app/src/shell/switcher/view.rsindex 859c1e20..b1bcf405 100644--- a/crates/rf-app/src/shell/switcher/view.rs+++ b/crates/rf-app/src/shell/switcher/view.rs@@ -91,18 +91,26 @@ pub struct SwitcherView {been_active: bool,/// Closing has been asked for; further keys and clicks do nothing.closing: bool,- /// Where the pointer was when the switcher opened (screen px), and whether it has moved since. WHY (issue 431: "the card under- /// the pointer is selected instead of the most recent previous window"): Windows tells a window that appears under a still- /// pointer that the mouse moved over it, so the card under it took the selection although the mouse was never touched. A card- /// is chosen by hovering only once the pointer has really moved.- pointer_at_open: Option<(i32, i32)>,- pointer_moved: bool,+ /// Where the pointer rested (screen px) when the switcher opened or when a key last moved the selection, and whether it has+ /// gone away from there since. A card is chosen by hovering only once the pointer has really gone somewhere. WHY, twice:+ /// (issue 431: "the card under the pointer is selected instead of the most recent previous window") Windows tells a window+ /// that appears under a still pointer that the mouse moved over it, so the card under it took the selection although the mouse+ /// was never touched; and (reported on Discord, 2026-12-04: "when i try to switch tab with keyboard it always got interrupted+ /// by mouse") a hand resting on the mouse moves it a pixel or two, which counted as a move and took the selection away from+ /// the keys in the middle of Alt+Tab. So a move has to be longer than `POINTER_SLACK`, and each step by a key starts the+ /// measure anew from where the pointer is then.+ pointer_rest: Option<(i32, i32)>,+ pointer_free: bool,_subs: Vec<gpui_kit::Subscription>,}-/// Whether the pointer is where it was when the switcher opened (`None` for either: it cannot be told, so it counts as moved).-fn pointer_still(at_open: Option<(i32, i32)>, now: Option<(i32, i32)>) -> bool {- matches!((at_open, now), (Some(a), Some(b)) if a == b)+/// How far (px at 100 % scale, along either axis) the pointer may drift from where it rested and still count as resting: more than+/// a hand lying on the mouse moves it, far less than the way to another card.+const POINTER_SLACK: f32 = 12.0;++/// Whether the pointer still rests where it did (`None` for either: it cannot be told, so it counts as moved).+fn pointer_rests(rest: Option<(i32, i32)>, now: Option<(i32, i32)>, slack: i32) -> bool {+ matches!((rest, now), (Some(a), Some(b)) if (a.0 - b.0).abs() <= slack && (a.1 - b.1).abs() <= slack)}impl SwitcherView {@@ -146,8 +154,8 @@ impl SwitcherView {focus: cx.focus_handle(),been_active: false,closing: false,- pointer_at_open: rf_win::dock::panel::cursor(),- pointer_moved: false,+ pointer_rest: rf_win::dock::panel::cursor(),+ pointer_free: false,_subs: vec![sub],}}@@ -281,7 +289,12 @@ impl SwitcherView {}match self.session.apply(effect) {Step::Nothing => {}- Step::Redraw => cx.notify(),+ Step::Redraw => {+ // a key moved the selection: the pointer has to go somewhere again before hovering takes it back+ self.pointer_rest = rf_win::dock::panel::cursor();+ self.pointer_free = false;+ cx.notify();+ }Step::Choose(hwnd) => self.finish(Closing::Chosen(hwnd), cx),Step::Cancel => self.finish(Closing::Cancelled, cx),Step::Close(hwnd, pid) => self.after_close(hwnd, pid, cx),@@ -343,11 +356,12 @@ impl SwitcherView {}fn hover(&mut self, i: usize, cx: &mut Context<Self>) {- if !self.pointer_moved {- if pointer_still(self.pointer_at_open, rf_win::dock::panel::cursor()) {+ if !self.pointer_free {+ let slack = (POINTER_SLACK * self.layout.scale).round() as i32;+ if pointer_rests(self.pointer_rest, rf_win::dock::panel::cursor(), slack) {return;}- self.pointer_moved = true;+ self.pointer_free = true;}if !self.closing && self.session.hover(i) == Step::Redraw {cx.notify();@@ -484,13 +498,22 @@ impl Render for SwitcherView {#[cfg(test)]mod tests {- use super::pointer_still;+ use super::pointer_rests;#[test]fn a_card_under_a_pointer_that_never_moved_is_not_chosen_by_hovering() {- assert!(pointer_still(Some((800, 500)), Some((800, 500))), "the window appeared under a still pointer");- assert!(!pointer_still(Some((800, 500)), Some((801, 500))), "a real move");- assert!(!pointer_still(None, Some((800, 500))), "unknown at the start: hovering works as before");- assert!(!pointer_still(Some((800, 500)), None));+ assert!(pointer_rests(Some((800, 500)), Some((800, 500)), 12), "the window appeared under a still pointer");+ assert!(!pointer_rests(None, Some((800, 500)), 12), "unknown at the start: hovering works as before");+ assert!(!pointer_rests(Some((800, 500)), None, 12));+ }++ /// A hand lying on the mouse moves the pointer a little: that is not a choice. Going on towards a card is.+ #[test]+ fn a_pointer_that_only_trembles_is_resting_and_one_that_goes_somewhere_is_not() {+ assert!(pointer_rests(Some((800, 500)), Some((803, 498)), 12), "a pixel or two");+ assert!(pointer_rests(Some((800, 500)), Some((788, 512)), 12), "up to the slack, either way");+ assert!(!pointer_rests(Some((800, 500)), Some((813, 500)), 12), "past the slack, across");+ assert!(!pointer_rests(Some((800, 500)), Some((800, 487)), 12), "past the slack, up");+ assert!(!pointer_rests(Some((800, 500)), Some((801, 500)), 0), "with no slack any move counts");}}