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
Revert the dock band recovery of #747 (777)
gelenmedya462d50d6372f
diff --git a/crates/rf-shellguard/src/tbctl.rs b/crates/rf-shellguard/src/tbctl.rsindex 48feaa2c..e8b89ba7 100644--- a/crates/rf-shellguard/src/tbctl.rs+++ b/crates/rf-shellguard/src/tbctl.rs@@ -85,8 +85,6 @@ pub trait HideWorld {let _ = from;self.set_work_area(to)}- /// Refit ordinary maximized windows that opened at full monitor size after a quiet work-area change.- fn repair_maximized(&mut self, _work: [i32; 4]) {}/// The dock takes the bottom edge: its placement is told that its band is `edge` (the bottom strip of the primary monitor; empty/// when the dock reserves nothing) and its own desktop-toolbar registration with Explorer is given back and stays given back./// Does not wait: [`HideWorld::dock_edge_ready`] says when the registration is gone. Telling it again only updates the strip.@@ -150,7 +148,6 @@ pub struct Controller {guard_fault: Option<Refusal>,guard_confirmed_ms: u64,throttle: Throttle,- recovery_throttle: Throttle,/// 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])>,@@ -197,10 +194,6 @@ impl Controller {guard_confirmed_ms: 0,// Explorer may recompute the work area whenever it likes: give it back at most 4 times a minute.throttle: Throttle::new(4, 60_000),- // One recovery a minute beyond `throttle` (issue 777: at one every two seconds, a full-screen app on the other monitor- // made Explorer reset this work area as often, and the two fought without end: the taskbar and the dock flickered and- // maximized windows were resized up and down).- recovery_throttle: Throttle::new(1, 60_000),held: Vec::new(),throttle_said: false,band_owed: false,@@ -368,7 +361,6 @@ impl Controller {/// not refused for the ones before it (a monitor switched off and on would otherwise wait up to a minute for the strip).pub fn screens_changed(&mut self, w: &mut dyn HideWorld) {self.throttle.reset();- self.recovery_throttle.reset();self.displays_changed(w);}@@ -737,7 +729,7 @@ impl Controller {}fn set_changes(&mut self, w: &mut dyn HideWorld, now: u64, plan: &tbwork::EdgePlan) {- let mut changes = plan.changes();+ let changes = plan.changes();if changes.is_empty() {self.band_owed = false;return;@@ -751,19 +743,11 @@ impl Controller {// of its band is not Explorer's doing: the thin dock changes it as windows are maximised and restored, never faster than// every two seconds, and the work area must be the one the dock stands under at every one of them.)if !std::mem::take(&mut self.band_owed) && !self.throttle.allow(now) {- // A completely lost band that was already ours leaves maximized apps under the dock.- // Recover that known reservation promptly, while still limiting repeated writes.- changes.retain(|c| {- plan.monitors.iter().any(|m| m.id == c.id && m.rect == c.from && c.to != m.rect)- && self.held.iter().any(|(id, rect)| id == &c.id && *rect == c.to)- });- if changes.is_empty() || !self.recovery_throttle.allow(now) {- if !self.throttle_said {- self.throttle_said = true;- w.warn("taskbar: the work area was set too often lately; left alone");- }- return;+ if !self.throttle_said {+ self.throttle_said = true;+ w.warn("taskbar: the work area was set too often lately; left alone");}+ return;}self.throttle_said = false;for c in &changes {@@ -771,12 +755,6 @@ impl Controller {Ok(()) => {self.held.retain(|(id, _)| *id != c.id);self.held.push((c.id.clone(), c.to));- // Maximized windows that opened at the monitor's full size while the band was lost are fitted to it, only here,- // where the work area was really set: before the throttle (until issue 777) they were fitted to a work area that- // was then not written, and Explorer's grew them back.- if c.from != c.to {- w.repair_maximized(c.to);- }}Err(e) => w.warn(&format!("taskbar: a work area could not be set: {e}")),}diff --git a/crates/rf-shellguard/src/tbedge_tests.rs b/crates/rf-shellguard/src/tbedge_tests.rsindex 1c8a87f2..3fad2e2e 100644--- a/crates/rf-shellguard/src/tbedge_tests.rs+++ b/crates/rf-shellguard/src/tbedge_tests.rs@@ -240,31 +240,6 @@ fn settled() -> (Controller, FakeWorld) {(c, w)}-#[test]-fn a_parked_taskbar_losing_the_entire_band_recovers_even_after_the_normal_throttle() {- let (mut c, mut w) = settled();- for _ in 0..8 {- w.monitors[0].work = [0, 0, 2560, 1392];- w.now += 1_000;- c.work_area_changed(&mut w);- }- w.desktop.borrow_mut().iter_mut().find(|x| x.class == PRIMARY).unwrap().rect = [0, 1438, 2560, 1486];- w.monitors[0].work = A;- c.tick(&mut w);- assert_eq!(work_a(&w), [0, 0, 2560, 1362]);-- // Explorer taking it again and again (a full-screen app on another monitor, issue 777): no fight, one recovery a minute- for _ in 0..20 {- w.monitors[0].work = A;- w.now += 2_000;- c.tick(&mut w);- assert_eq!(work_a(&w), A, "repeated recovery is rate limited");- }- w.now += 21_000;- c.tick(&mut w);- assert_eq!(work_a(&w), [0, 0, 2560, 1362]);-}-#[test]fn switching_off_puts_things_back_in_a_fixed_order_and_the_dock_registers_its_band_again() {let (mut c, mut w) = settled();diff --git a/crates/rf-shellguard/src/tbmodel.rs b/crates/rf-shellguard/src/tbmodel.rsindex 873b19f9..5ab66c21 100644--- a/crates/rf-shellguard/src/tbmodel.rs+++ b/crates/rf-shellguard/src/tbmodel.rs@@ -274,12 +274,12 @@ pub struct MonitorGeom {////// A maximized window overhangs the work area by its frame on every side (8 px for most, 0 for some): each edge keeps its overhang./// A window that was not fitted to `from` (an earlier quiet change it missed) takes the overhang of its left and top edges for the-/// right and bottom. A window that is exactly the monitor is only fitted when its native style confirms it is ordinarily-/// maximized. Windows whose edges fit neither reading, and windows already where they belong, are left alone.-pub fn refit_maximized(win: [i32; 4], monitor: [i32; 4], from: [i32; 4], to: [i32; 4], ordinary: bool) -> Option<[i32; 4]> {+/// right and bottom. Left alone: a window that is exactly the monitor (a borderless full-screen program that calls itself+/// maximized), one whose edges fit neither reading, and one that is already where it belongs.+pub fn refit_maximized(win: [i32; 4], monitor: [i32; 4], from: [i32; 4], to: [i32; 4]) -> Option<[i32; 4]> {const FRAME: std::ops::RangeInclusive<i32> = 0..=32;if win == monitor {- return (ordinary && to != win && to[2] > to[0] && to[3] > to[1]).then_some(to);+ return None;}let over = [from[0] - win[0], from[1] - win[1], win[2] - from[2], win[3] - from[3]];let new = if over.iter().all(|o| FRAME.contains(o)) {@@ -350,23 +350,21 @@ mod tests {let mon = [0, 0, 2560, 1440];let (old, new) = ([0, 0, 2560, 1392], [0, 0, 2560, 1362]);// the usual 8 px frame: every edge keeps its overhang (measured: a browser at -8,-8 2576x1408 on the 1392 work area)- assert_eq!(refit_maximized([-8, -8, 2568, 1400], mon, old, new, true), Some([-8, -8, 2568, 1370]));+ assert_eq!(refit_maximized([-8, -8, 2568, 1400], mon, old, new), Some([-8, -8, 2568, 1370]));// a window without overhang- assert_eq!(refit_maximized([0, 0, 2560, 1392], mon, old, new, true), Some([0, 0, 2560, 1362]));+ assert_eq!(refit_maximized([0, 0, 2560, 1392], mon, old, new), Some([0, 0, 2560, 1362]));// the work area grows to the whole monitor (a second monitor whose taskbar strip is given back) and shrinks againlet side = [2560, -618, 4000, 1942];let side_old = [2560, -618, 4000, 1894];- assert_eq!(refit_maximized([2552, -626, 4008, 1902], side, side_old, side, true), Some([2552, -626, 4008, 1950]));- assert_eq!(refit_maximized([2552, -626, 4008, 1950], side, side, side_old, true), Some([2552, -626, 4008, 1902]));+ assert_eq!(refit_maximized([2552, -626, 4008, 1902], side, side_old, side), Some([2552, -626, 4008, 1950]));+ assert_eq!(refit_maximized([2552, -626, 4008, 1950], side, side, side_old), Some([2552, -626, 4008, 1902]));// it missed an earlier change (still fitted to an older, larger area): the left and top overhang decide- assert_eq!(refit_maximized([-8, -8, 2568, 1448], mon, old, new, true), Some([-8, -8, 2568, 1370]));+ assert_eq!(refit_maximized([-8, -8, 2568, 1448], mon, old, new), Some([-8, -8, 2568, 1370]));// exactly the monitor: a full-screen program, not ours to move- assert_eq!(refit_maximized(mon, mon, old, new, false), None);- assert_eq!(refit_maximized(mon, mon, mon, new, true), Some(new));- assert_eq!(refit_maximized(mon, mon, mon, mon, true), None);+ assert_eq!(refit_maximized(mon, mon, old, new), None);// already there, or placed by its own rules- assert_eq!(refit_maximized([-8, -8, 2568, 1370], mon, new, new, true), None);- assert_eq!(refit_maximized([300, 200, 1500, 900], mon, old, new, true), None);+ assert_eq!(refit_maximized([-8, -8, 2568, 1370], mon, new, new), None);+ assert_eq!(refit_maximized([300, 200, 1500, 900], mon, old, new), None);}fn live(handle: isize, class: &str, pid: u32, start: u64, visible: bool) -> LiveWindow {diff --git a/crates/rf-shellguard/src/tbwork.rs b/crates/rf-shellguard/src/tbwork.rsindex dbd0e955..e8d3e07a 100644--- a/crates/rf-shellguard/src/tbwork.rs+++ b/crates/rf-shellguard/src/tbwork.rs@@ -82,12 +82,6 @@ fn inside(inner: [i32; 4], outer: [i32; 4]) -> bool {inner[2] > inner[0] && inner[3] > inner[1] && inner[0] >= outer[0] && inner[1] >= outer[1] && inner[2] <= outer[2] && inner[3] <= outer[3]}-// Explorer can park an auto-hiding taskbar below the screen, leaving only a few pixels at the edge.-fn parked_bottom(monitor: [i32; 4], bar: [i32; 4]) -> bool {- (1..=8).contains(&(monitor[3] - bar[1])) && bar[3] > monitor[3] + 1- && bar[3] - bar[1] < (monitor[3] - monitor[1]) / 2-}-/// The edge a bar is on: it spans (nearly) the whole monitor along that edge and touches it. `None`: it is not a bar on an edge.pub fn side_of(monitor: [i32; 4], bar: [i32; 4]) -> Option<Side> {let (mw, mh) = (monitor[2] - monitor[0], monitor[3] - monitor[1]);@@ -97,7 +91,7 @@ pub fn side_of(monitor: [i32; 4], bar: [i32; 4]) -> Option<Side> {}let wide = i64::from(bw) * 10 >= i64::from(mw) * 9;let tall = i64::from(bh) * 10 >= i64::from(mh) * 9;- if wide && (near(bar[3], monitor[3]) || parked_bottom(monitor, bar)) && bar[1] > monitor[1] + mh / 2 {+ if wide && near(bar[3], monitor[3]) && bar[1] > monitor[1] + mh / 2 {Some(Side::Bottom)} else if wide && near(bar[1], monitor[1]) && bar[3] < monitor[1] + mh / 2 {Some(Side::Top)@@ -112,9 +106,6 @@ pub fn side_of(monitor: [i32; 4], bar: [i32; 4]) -> Option<Side> {/// The work area with only an identified edge taskbar reserving room.pub fn without_strip(monitor: [i32; 4], bar: [i32; 4]) -> [i32; 4] {- if parked_bottom(monitor, bar) {- return monitor;- }let [l, t, r, b] = monitor;match side_of(monitor, bar) {Some(Side::Left) => [bar[2], t, r, b],@@ -358,20 +349,6 @@ mod tests {p.monitors.iter().map(|m| m.verdict).collect()}- #[test]- fn parked_taskbar_at_125_percent_scale_allows_the_docks_band_to_be_recovered() {- let monitor = [0, 0, 1920, 1080];- let parked = [0, 1078, 1920, 1138];- let target = [0, 0, 1920, 1010];- assert_eq!(side_of(monitor, parked), Some(Side::Bottom));- assert_eq!(without_strip(monitor, parked), monitor);- let plan = plan_edge(&[mon("A", monitor, monitor, true)], &[parked], Some(70));- assert_eq!(plan.changes(), vec![WorkChange { id: "A".into(), from: monitor, to: target }]);- assert_eq!(plan.primary().unwrap().user_work, monitor);- let foreign = plan_edge(&[mon("A", monitor, [0, 30, 1920, 1080], true)], &[parked], Some(70));- assert_eq!(verdicts(&foreign), vec![Verdict::Foreign]);- }-// ---------------------------------------------------------------- the target#[test]diff --git a/crates/rf-win/src/dock/fullscreen.rs b/crates/rf-win/src/dock/fullscreen.rsindex cc220725..eaa11ed9 100644--- a/crates/rf-win/src/dock/fullscreen.rs+++ b/crates/rf-win/src/dock/fullscreen.rs@@ -86,7 +86,7 @@ pub fn is_borderless_popup(style: u32) -> bool {}/// Reads window information for any given HWND. `None` when there is none or it cannot be measured.-pub(crate) fn window_info(h: windows::Win32::Foundation::HWND) -> Option<Foreground> {+fn window_info(h: windows::Win32::Foundation::HWND) -> Option<Foreground> {use windows::Win32::Foundation::RECT;use windows::Win32::System::Threading::GetCurrentProcessId;use windows::Win32::UI::WindowsAndMessaging::{GWL_STYLE, GetClassNameW, GetWindowLongPtrW, GetWindowRect, GetWindowThreadProcessId};diff --git a/crates/rf-win/src/taskbar_hide.rs b/crates/rf-win/src/taskbar_hide.rsindex 950ab961..f9cb6412 100644--- a/crates/rf-win/src/taskbar_hide.rs+++ b/crates/rf-win/src/taskbar_hide.rs@@ -224,10 +224,6 @@ impl HideWorld for RealWorld {Ok(())}- fn repair_maximized(&mut self, work: [i32; 4]) {- crate::workfit::repair_maximized(work);- }-fn load_state(&mut self) -> ShellStateFile {ShellStateFile::load(&self.state_path())}diff --git a/crates/rf-win/src/workfit.rs b/crates/rf-win/src/workfit.rsindex b9dbe6b7..ec56e407 100644--- a/crates/rf-win/src/workfit.rs+++ b/crates/rf-win/src/workfit.rs@@ -24,24 +24,14 @@ struct Fit {monitor: HMONITOR,monitor_rect: [i32; 4],own: u32,- monitor_sized_only: bool,}/// Asks every visible maximized window of the monitor that holds `to` (not this process's own) to take the place it has in the work/// area `to`, given that the monitor's work area was `from`. Queued (a program that hangs does not hold the caller); a window of a/// higher integrity level refuses and stays as it is. Call it on a per-monitor DPI aware thread: the rectangles are physical pixels.pub fn maximized_windows(from: [i32; 4], to: [i32; 4]) {- fit_windows(from, to, false);-}--/// Catch an ordinary maximized window that missed the quiet change or opened just after it.-pub(crate) fn repair_maximized(work: [i32; 4]) {- fit_windows(work, work, true);-}--fn fit_windows(from: [i32; 4], to: [i32; 4], monitor_sized_only: bool) {let [left, top, right, bottom] = to;- let mut fit = Fit { from, to, monitor: HMONITOR::default(), monitor_rect: [0; 4], own: std::process::id(), monitor_sized_only };+ let mut fit = Fit { from, to, monitor: HMONITOR::default(), monitor_rect: [0; 4], own: std::process::id() };// SAFETY: plain queries; `fit` outlives EnumWindows, which calls back on this thread.unsafe {fit.monitor = MonitorFromRect(&RECT { left, top, right, bottom }, MONITOR_DEFAULTTONULL);@@ -68,15 +58,7 @@ unsafe extern "system" fn each(hwnd: HWND, lparam: LPARAM) -> BOOL {if pid == fit.own || GetWindowRect(hwnd, &mut r).is_err() {return true.into();}- let rect = [r.left, r.top, r.right, r.bottom];- if fit.monitor_sized_only && rect != fit.monitor_rect {- return true.into();- }- // An ordinary maximized window can fill the monitor exactly when Explorer loses the reserved band.- let ordinary = rect == fit.monitor_rect && crate::dock::fullscreen::window_info(hwnd).is_some_and(|fg| {- !fg.shell && !fg.own && (fg.maximized_frame || (fg.caption && !fg.uwp_frame && !fg.borderless_popup))- });- if let Some([l, t, rr, b]) = rf_shellguard::tbmodel::refit_maximized(rect, fit.monitor_rect, fit.from, fit.to, ordinary) {+ if let Some([l, t, rr, b]) = rf_shellguard::tbmodel::refit_maximized([r.left, r.top, r.right, r.bottom], fit.monitor_rect, fit.from, fit.to) {let _ = SetWindowPos(HWND(hwnd.0 as *mut c_void), None, l, t, rr - l, b - t, SWP_ASYNCWINDOWPOS | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);}true.into()