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
The thin dock grows for a pointer that comes to rest on it, not for one that only crosses
gelenmedya2c15b2654154
diff --git a/crates/rf-app/src/dock/thin.rs b/crates/rf-app/src/dock/thin.rsindex 9c80da04..01d6c6e3 100644--- a/crates/rf-app/src/dock/thin.rs+++ b/crates/rf-app/src/dock/thin.rs@@ -320,7 +320,9 @@ fn zone_now(mon: MonId, cx: &App) -> Option<Zone> {Some(rf_win::dock::thin::zone(axes(full), axes(left), axes(right), axes(monitor), unit))}-/// The pointer is on this dock's island (its mouse events say so): near, at once, without waiting for the next look at the cursor.+/// The pointer is on this dock's island (its mouse events say so): the cursor is looked at now, without waiting for the poller's+/// next turn. It does not make the dock near by itself any more: a pointer that only crosses the thin dock is on the island for a+/// moment too, and the dock grew for it (`rf_win::dock::thin::Intent`: it has to come to rest, or press).pub fn pointer_on_island(mon: MonId, cx: &mut App) {if !ENABLED.load(Ordering::Relaxed) {return;@@ -328,8 +330,7 @@ pub fn pointer_on_island(mon: MonId, cx: &mut App) {let Some(h) = me(cx) else { return };let Some(m) = h.mon_mut(mon) else { return };if m.model.inputs.enabled && m.model.inputs.maximized && !m.model.inputs.near {- m.model.inputs.near = true;- reevaluate(mon, cx);+ let _ = poll(cx);}}@@ -449,6 +450,8 @@ fn poll(cx: &mut App) -> Option<u64> {return None;}let button = pointer.is_some_and(|(_, _, down)| down);+ let now = h.now_ms();+ let mut waiting = false;let mut changed = Vec::new();for m in &mut h.mons {if !m.model.needs_polling() {@@ -459,17 +462,22 @@ fn poll(cx: &mut App) -> Option<u64> {let near = m.model.inputs.near;let inside = m.zone.map(|z| pointer.is_some_and(|(x, y, _)| z.holds(x, y, near)));// (a panel, a menu or a preview keeps the dock it belongs to grown, and no other)- if m.model.observe(inside, button, open && active == m.mon) {+ // (a pointer over the thin glass is near only once it has come to rest there, or pressed: `thin::Intent`)+ let at = pointer.map(|(x, y, _)| (x, y));+ let (moved, waits) = m.model.observe_pointer(now, at, inside, button, open && active == m.mon, m.zone.map_or(0, |z| z.slack));+ waiting |= waits;+ if moved {changed.push(m.mon);}}for id in changed {reevaluate(id, cx);}- Some(next_poll(cx.try_global::<ThinHost>().is_some_and(|h| h.mons.iter().any(|m| m.model.inputs.near))))+ Some(next_poll(waiting || cx.try_global::<ThinHost>().is_some_and(|h| h.mons.iter().any(|m| m.model.inputs.near))))}-/// The time to the next look at the cursor: every frame while the pointer is at a dock, else [`POLL_MS`].+/// The time to the next look at the cursor: every frame while the pointer is at a dock (grown under it, or over the thin glass+/// and not yet at rest), else [`POLL_MS`].fn next_poll(near: bool) -> u64 {if near { POLL_NEAR_MS } else { POLL_MS }}diff --git a/crates/rf-win/src/dock/thin.rs b/crates/rf-win/src/dock/thin.rsindex 11448785..20a5d742 100644--- a/crates/rf-win/src/dock/thin.rs+++ b/crates/rf-win/src/dock/thin.rs@@ -133,6 +133,8 @@ pub struct Zone {pub enter: Rect,pub left: Rect,pub right: Rect,+ /// [`INTENT_SLACK`] in device px for this dock.+ pub slack: i32,}impl Zone {@@ -165,7 +167,46 @@ pub fn zone(full: Rect, left: Rect, right: Rect, monitor: Rect, unit: f32) -> Zobottom: monitor.bottom,};let enter = Rect { bottom: monitor.bottom, ..thin };- Zone { near, enter, left, right }+ Zone { near, enter, left, right, slack: px(INTENT_SLACK, unit) }+}++// ---------------------------------------------------------------- the pointer that means it++/// How far the pointer may drift (units at 100 %), and for how long it has to keep within that, before it counts as having come+/// to the thin dock.+///+/// WHY. A thin dock grew the moment the pointer was over its glass, so it also grew for a pointer that was only on its way across+/// the bottom of the screen (to a window's status bar, to the other monitor, to a corner): a flash of the full dock over the+/// window each time. A pointer that MEANS the dock slows down on it. So the dock grows once the pointer has stayed within 5 units+/// of one place for 50 ms, or at once for a press. Crossing at speed never does that: at a look every 16 ms a pointer faster+/// than about 100 units a second leaves the 5 units before the 50 ms are over. Staying grown is not judged this way (the large+/// area and no wait, as before): only the coming.+pub const INTENT_SLACK: f32 = 5.0;+pub const INTENT_MS: u64 = 50;++/// Where the pointer has been resting, and since when.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]+pub struct Intent {+ rest: Option<(i32, i32, u64)>,+}++impl Intent {+ /// One look at the pointer at `now` (ms) while it is in the area that makes a thin dock grow. True once it has kept within+ /// `slack` px of one place for [`INTENT_MS`].+ pub fn inside(&mut self, now: u64, x: i32, y: i32, slack: i32) -> bool {+ match self.rest {+ Some((rx, ry, since)) if (x - rx).abs() <= slack && (y - ry).abs() <= slack => now.saturating_sub(since) >= INTENT_MS,+ _ => {+ self.rest = Some((x, y, now));+ false+ }+ }+ }++ /// The pointer is not in that area (or the dock is grown already): the next coming is measured anew.+ pub fn outside(&mut self) {+ self.rest = None;+ }}// ---------------------------------------------------------------- thin or full@@ -306,6 +347,7 @@ pub struct Model {pub inputs: Inputs,follower: Follower,band: BandRule,+ intent: Intent,}/// What [`Model::look`] answers.@@ -360,6 +402,29 @@ impl Model {changed}+ /// [`Model::observe`] for a look that knows where the pointer is: a pointer in the area that makes a thin dock grow counts as+ /// near only once it has come to rest there ([`Intent`]) or a button is pressed. `at`: the pointer, `inside` as for `observe`,+ /// `slack`: the zone's. Returns whether `near` or `open` changed, and whether a pointer is being waited on (the caller looks+ /// again soon then: a pointer that has stopped sends no more events).+ pub fn observe_pointer(&mut self, now: u64, at: Option<(i32, i32)>, inside: Option<bool>, button: bool, open: bool, slack: i32) -> (bool, bool) {+ let mut waiting = false;+ let inside = match (inside, at) {+ (Some(true), Some((x, y))) if self.inputs.maximized && !self.inputs.near => {+ if button || self.intent.inside(now, x, y, slack) {+ Some(true)+ } else {+ waiting = true;+ Some(false)+ }+ }+ (other, _) => {+ self.intent.outside();+ other+ }+ };+ (self.observe(inside, button, open), waiting)+ }+/// The setting was switched off: the dock of today, at once, and the full band back. True: the band was the thin one, so it/// must be set again.pub fn switch_off(&mut self) -> bool {@@ -457,6 +522,49 @@ mod tests {assert_eq!(f.step(60_000, on(true, false, false)), Verdict { thin: true, wake_at: None });}+ /// (the user, 2026-12-04: a wrong hover on the dock; "5 points and 50 ms")+ #[test]+ fn a_pointer_that_only_crosses_the_thin_dock_does_not_grow_it_and_one_that_rests_or_presses_does() {+ let thin = || {+ let mut m = Model::new();+ m.inputs.enabled = true;+ m.inputs.maximized = true;+ m+ };+ // crossing: 12 px at every look, a look every 16 ms+ let mut m = thin();+ for k in 0..8u64 {+ assert_eq!(m.observe_pointer(k * 16, Some((100 + 12 * k as i32, 500)), Some(true), false, false, 5), (false, true), "look {k}");+ }+ assert!(!m.inputs.near);+ // a slow drift across (2 px a look, 125 px a second) leaves the 5 px before the 50 ms are over each time+ for k in 0..20u64 {+ m.observe_pointer(200 + k * 16, Some((100 + 2 * k as i32, 500)), Some(true), false, false, 5);+ }+ assert!(!m.inputs.near);+ // it leaves, comes again and rests: within 5 px for 50 ms+ assert_eq!(m.observe_pointer(900, Some((300, 100)), Some(false), false, false, 5), (false, false));+ assert_eq!(m.observe_pointer(1_000, Some((100, 500)), Some(true), false, false, 5), (false, true));+ assert_eq!(m.observe_pointer(1_016, Some((102, 501)), Some(true), false, false, 5), (false, true));+ assert_eq!(m.observe_pointer(1_032, Some((103, 500)), Some(true), false, false, 5), (false, true));+ assert_eq!(m.observe_pointer(1_050, Some((103, 500)), Some(true), false, false, 5), (true, false), "at rest for 50 ms: near");+ assert!(m.inputs.near);+ // once grown it stays near as before: anywhere in the large area, with no wait+ assert_eq!(m.observe_pointer(1_066, Some((400, 440)), Some(true), false, false, 5), (false, false));+ assert!(m.inputs.near);+ // gone thin again, the next coming is measured anew+ assert_eq!(m.observe_pointer(1_100, Some((400, 100)), Some(false), false, false, 5), (true, false));+ assert_eq!(m.observe_pointer(1_116, Some((103, 500)), Some(true), false, false, 5), (false, true));+ // a press on the thin dock is meant at once+ let mut p = thin();+ assert_eq!(p.observe_pointer(0, Some((100, 500)), Some(true), true, false, 5), (true, false));+ assert!(p.inputs.near);+ // with no window on the band nothing is near, as before+ let mut off = Model::new();+ off.inputs.enabled = true;+ assert_eq!(off.observe_pointer(0, Some((100, 500)), Some(true), false, false, 5), (false, false));+ }+#[test]fn the_pointer_near_or_something_open_grows_it_at_once() {let mut f = Follower::new();