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
Maximised windows go back above the Dock within seconds of Explorer taking the room (883, 888)
denfryd64b11b63b87
diff --git a/crates/rf-shellguard/src/tbctl.rs b/crates/rf-shellguard/src/tbctl.rsindex 92eeea89..49a9ce72 100644--- a/crates/rf-shellguard/src/tbctl.rs+++ b/crates/rf-shellguard/src/tbctl.rs@@ -29,7 +29,7 @@//! until a guard is confirmed again.use crate::statefile::ShellStateFile;-use crate::tbmodel::{self, Gate, GuardStatus, HideRecord, LiveWindow, MonitorGeom, Refusal, Target, Throttle};+use crate::tbmodel::{self, Gate, GuardStatus, HideRecord, LiveWindow, MonitorGeom, Refusal, Target, Backoff};use crate::tbwork::{self, Verdict};/// How long the host waits for the guard to say it is armed.@@ -149,7 +149,7 @@ pub struct Controller {/// 60 seconds. `None` while a guard is confirmed or none was wanted yet.guard_fault: Option<Refusal>,guard_confirmed_ms: u64,- throttle: Throttle,+ throttle: Backoff,/// The work area this controller last set for each monitor it changed (monitor id, rectangle): a work area that is one of them/// is ours (`tbwork::plan_edge_held`). Forgotten when the edge is given back and when the user's rectangles are put back.held: Vec<(String, [i32; 4])>,@@ -194,8 +194,9 @@ impl Controller {next_guard_try_ms: 0,guard_fault: None,guard_confirmed_ms: 0,- // Explorer may recompute the work area whenever it likes: give it back at most once a minute.- throttle: Throttle::new(1, 60_000),+ // Explorer may recompute the work area whenever it likes: give it back at once, then after 2, 4, 8 ... seconds, and at most+ // once a minute while it keeps taking it.+ throttle: Backoff::new(2_000, 60_000),held: Vec::new(),throttle_said: false,band_owed: false,@@ -373,7 +374,7 @@ impl Controller {}/// The work area was changed by someone (Explorer recomputes it when a toolbar changes): while the edge is ours it is set again,- /// once a minute at most.+ /// with growing pauses (`Backoff`).pub fn work_area_changed(&mut self, w: &mut dyn HideWorld) {if self.want && !self.hidden.is_empty() {self.drive_edge(w);diff --git a/crates/rf-shellguard/src/tbedge_tests.rs b/crates/rf-shellguard/src/tbedge_tests.rsindex 800cff21..f694f0f3 100644--- a/crates/rf-shellguard/src/tbedge_tests.rs+++ b/crates/rf-shellguard/src/tbedge_tests.rs@@ -355,8 +355,8 @@ fn explorer_taking_the_strip_back_is_answered_a_few_times_and_then_left_alone()w.now += 1_000;c.work_area_changed(&mut w);}- // Initial acquisition is free; only one unsolicited recovery is allowed per minute.- assert_eq!(w.work_sets.len(), first + 1, "{:?}", w.work_sets);+ // answered after 1, 3 and 7 s (pauses of 2 and 4 s), not every second+ assert_eq!(w.work_sets.len(), first + 3, "{:?}", w.work_sets);assert!(w.lines.iter().any(|l| l.contains("too often")));// and a minute later it is answered againw.now += 60_000;@@ -386,7 +386,7 @@ fn a_display_change_after_explorer_was_throttled_sets_the_work_area_again_at_oncw.now += 1_000;c.work_area_changed(&mut w);}- assert_eq!(w.work_sets.len(), before, "{:?}", w.work_sets);+ assert_eq!(w.work_sets.len(), before + 2, "after 2 and 6 s, not every second: {:?}", w.work_sets);}#[test]@@ -468,7 +468,7 @@ fn explorer_taking_the_work_area_back_is_still_throttled_after_the_docks_own_chaw.now += 1_000;c.work_area_changed(&mut w);}- assert_eq!(w.work_sets.len(), before + 1, "{:?}", w.work_sets);+ assert_eq!(w.work_sets.len(), before + 3, "{:?}", w.work_sets);assert!(w.lines.iter().any(|l| l.contains("too often")));}@@ -858,7 +858,7 @@ fn fullscreen_on_any_monitor_leaves_parked_secondary_and_work_areas_alone_777()}#[test]-fn single_monitor_parked_taskbar_recovers_lost_band_at_most_once_per_minute() {+fn single_monitor_parked_taskbar_recovers_lost_band_soon_and_then_at_most_once_per_minute() {let (mut c, mut w) = world(true);w.monitors.truncate(1);w.desktop.borrow_mut().retain(|bar| bar.class == PRIMARY);@@ -869,14 +869,20 @@ fn single_monitor_parked_taskbar_recovers_lost_band_at_most_once_per_minute() {c.tick(&mut w);assert_eq!(work_a(&w), [0, 0, 2560, 1362]);let before = w.work_sets.len();- for _ in 0..59 {- w.now += 1_000;- w.monitors[0].work = A;- c.tick(&mut w);- }- assert_eq!(w.work_sets.len(), before);+ // Explorer takes the band back once: it is ours again two seconds later, not a minute later (issues 883, 888)+ w.now += 1_000;+ w.monitors[0].work = A;+ c.tick(&mut w);w.now += 1_000;c.tick(&mut w);assert_eq!(work_a(&w), [0, 0, 2560, 1362]);assert_eq!(w.work_sets.len(), before + 1);+ // it keeps taking it every second for ten minutes: the answers come further apart and then once a minute at most+ for _ in 0..600 {+ w.now += 1_000;+ w.monitors[0].work = A;+ c.tick(&mut w);+ }+ let answers = w.work_sets.len() - before;+ assert!((10..=16).contains(&answers), "{answers} answers in ten minutes");}diff --git a/crates/rf-shellguard/src/tbmodel.rs b/crates/rf-shellguard/src/tbmodel.rsindex 5ab66c21..3a7d8ee9 100644--- a/crates/rf-shellguard/src/tbmodel.rs+++ b/crates/rf-shellguard/src/tbmodel.rs@@ -313,31 +313,44 @@ pub fn originals_to_save(already: &[WorkAreaRec], changes: &[WorkChange]) -> Vecout}-/// At most `max` events in any `window_ms`: Explorer may recompute the work area whenever it likes, and setting it-/// again every time could fight it for ever.+/// Answers to a work area taken back: the first at once, each next one only after a pause twice as long as the one before+/// (`first_gap_ms` up to `max_gap_ms`), and the pauses start over when nobody asked for `max_gap_ms`. A work area that Explorer+/// recomputes now and then (a program starting, Steam did it twice within seconds) is set again within seconds; one that it keeps+/// taking back is answered at most once per `max_gap_ms` after a few tries, so the two never fight. A plain "once a minute" left+/// maximised windows under the dock for up to a minute after the second recompute (issues 883, 888).#[derive(Clone, Debug)]-pub struct Throttle {- stamps: Vec<u64>,- max: usize,- window_ms: u64,+pub struct Backoff {+ first_gap_ms: u64,+ max_gap_ms: u64,+ /// When the last answer was allowed, and the pause before the next one.+ last_allowed: Option<(u64, u64)>,+ /// When anyone last asked, allowed or not: a fight that goes on keeps the pauses long.+ last_asked: u64,}-impl Throttle {- pub fn new(max: usize, window_ms: u64) -> Throttle {- Throttle { stamps: Vec::new(), max, window_ms }+impl Backoff {+ pub fn new(first_gap_ms: u64, max_gap_ms: u64) -> Backoff {+ Backoff { first_gap_ms, max_gap_ms, last_allowed: None, last_asked: 0 }}pub fn allow(&mut self, now_ms: u64) -> bool {- self.stamps.retain(|t| now_ms.saturating_sub(*t) < self.window_ms);- if self.stamps.len() >= self.max {- return false;- }- self.stamps.push(now_ms);+ let quiet = now_ms.saturating_sub(self.last_asked) >= self.max_gap_ms;+ self.last_asked = now_ms;+ let gap = match self.last_allowed {+ Some((at, gap)) if !quiet => {+ if now_ms.saturating_sub(at) < gap {+ return false;+ }+ (gap * 2).min(self.max_gap_ms)+ }+ _ => self.first_gap_ms,+ };+ self.last_allowed = Some((now_ms, gap));true}pub fn reset(&mut self) {- self.stamps.clear();+ self.last_allowed = None;}}@@ -468,11 +481,27 @@ mod tests {}#[test]- fn the_throttle_allows_a_few_per_window_and_forgets_old_ones() {- let mut th = Throttle::new(3, 60_000);- assert!(th.allow(0) && th.allow(1_000) && th.allow(2_000));- assert!(!th.allow(3_000));- assert!(th.allow(60_500), "the first one has aged out");- assert!(!th.allow(60_600));+ fn the_backoff_answers_at_once_then_with_growing_pauses_and_starts_over_after_quiet() {+ let mut b = Backoff::new(2_000, 60_000);+ assert!(b.allow(0), "the first answer is at once");+ assert!(!b.allow(1_000));+ assert!(b.allow(2_000), "after the first pause");+ assert!(!b.allow(5_000));+ assert!(b.allow(6_000), "after a pause twice as long");+ // asked every second for ten minutes: the pauses grow to the longest and stay there+ let allowed: Vec<u64> = (7..600).map(|s| s * 1_000).filter(|&t| b.allow(t)).collect();+ assert_eq!(allowed[..4], [14_000, 30_000, 62_000, 122_000]);+ assert!(allowed[2..].windows(2).all(|w| w[1] - w[0] >= 60_000), "{allowed:?}");+ // a minute of quiet: the next one is at once again, and so is its pause short+ assert!(b.allow(700_000));+ assert!(b.allow(702_000));+ }++ #[test]+ fn a_reset_backoff_answers_at_once() {+ let mut b = Backoff::new(2_000, 60_000);+ assert!(b.allow(0) && b.allow(2_000) && !b.allow(3_000));+ b.reset();+ assert!(b.allow(3_100));}}