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
WIP: the dock keeps its bands registered with Explorer while the taskbar auto-hides (not working yet)
gelenmedyaafc6e1461c11
diff --git a/crates/rf-shellguard/src/tbctl.rs b/crates/rf-shellguard/src/tbctl.rsindex 56697000..4e9464ed 100644--- a/crates/rf-shellguard/src/tbctl.rs+++ b/crates/rf-shellguard/src/tbctl.rs@@ -77,6 +77,15 @@ pub trait HideWorld {fn monitors(&mut self) -> Vec<MonitorGeom>;/// Explorer may park taskbars on other monitors while any display is in full screen.fn any_fullscreen(&mut self) -> bool { false }+ /// Does Explorer's taskbar hide itself (its own auto-hide is on)? Then it reserves no strip, and a band that is registered with+ /// Explorer is the whole reservation - kept by Explorer through every recomputation of the work area. (A work area set behind+ /// Explorer's back is lost at each of them: measured, it came back seconds to a minute later, and never on a second monitor.)+ fn explorer_keeps_bands(&mut self) -> bool { false }+ /// The docks on the other monitors register these bands with Explorer themselves (monitor id, thickness in device px), as the+ /// dock on the primary monitor does with its own. An empty list: none, the registrations are given back. Does not wait.+ fn dock_other_bands(&mut self, bands: &[(String, i32)]) {+ let _ = bands;+ }/// Sets the session's work area for the monitor that holds `rect` (never stored: no profile update).fn set_work_area(&mut self, rect: [i32; 4]) -> Result<(), String>;/// Holds the work area of a monitor whose edge is ours while Explorer's taskbar is hidden: from `from` (what it has now) to `to`.@@ -179,6 +188,8 @@ pub struct Controller {next_edge_try_ms: u64,/// The "another toolbar reserves room" line was said already.foreign_said: bool,+ /// The bands the docks on the other monitors were last told to register with Explorer themselves (empty: none are).+ others_told: Vec<(String, i32)>,/// The last restore did not complete: it is tried again on the timer until it does (or the retries run out).restore_pending: bool,restore_attempts: u32,@@ -215,6 +226,7 @@ impl Controller {edge_failures: 0,next_edge_try_ms: 0,foreign_said: false,+ others_told: Vec::new(),restore_pending: false,restore_attempts: 0,next_restore_ms: 0,@@ -499,6 +511,9 @@ impl Controller {/// with no band and no hidden strip. Nothing else is put back: Explorer computed the work areas anew with the restart, and the/// written-down record stays for the way out. Called after a pass that left `hidden` empty; the next pass starts from `Free`.fn release_unheld_edge(&mut self, w: &mut dyn HideWorld) {+ if self.hidden.is_empty() {+ self.take_back_other_bands(w);+ }if !self.hidden.is_empty() || self.edge == Edge::Free {return;}@@ -660,6 +675,11 @@ impl Controller {}return;}+ if w.explorer_keeps_bands() {+ self.leave_edges_to_explorer(w);+ return;+ }+ self.take_back_other_bands(w);match self.edge {Edge::Free => {// the dock has not said what its band is: wait for its word (`set_band` drives the edge when it comes)@@ -701,6 +721,45 @@ impl Controller {}}+ /// Explorer's taskbar hides itself, so its strip is not in the work area: the edge is not taken. The dock keeps (or gets back) its+ /// own band registration and the docks on the other monitors register theirs, and Explorer computes every work area from them.+ /// Nothing is set here and nothing is written down: there is nothing of ours for Explorer to take back, and nothing to put back+ /// on the way out.+ fn leave_edges_to_explorer(&mut self, w: &mut dyn HideWorld) {+ if self.edge != Edge::Free {+ w.log("taskbar: Explorer's taskbar hides itself; the dock's band is Explorer's to keep and the edge is given back");+ w.dock_give_back_edge();+ self.dock_edge = None;+ self.edge = Edge::Free;+ self.held.clear();+ self.edge_failures = 0;+ self.next_edge_try_ms = 0;+ // The rectangles written down when the edge was taken are of a taskbar that kept its strip: nothing of ours is in the work+ // areas any more, so there is nothing to put back on the way out (the record of the hidden windows stays).+ let mut st = w.load_state();+ if !st.original_work_areas().is_empty() {+ st.set_original_work_areas(&[]);+ if let Err(e) = w.save_state(&st) {+ w.warn(&format!("taskbar: the written-down work areas could not be removed from the state file: {e}"));+ }+ }+ }+ self.band_owed = false;+ if self.others_told != self.other_bands {+ w.dock_other_bands(&self.other_bands);+ self.others_told.clone_from(&self.other_bands);+ }+ }++ /// The docks on the other monitors give their registrations back: their bands are set by this controller again (the edge is+ /// taken), or the hide is over.+ fn take_back_other_bands(&mut self, w: &mut dyn HideWorld) {+ if !self.others_told.is_empty() {+ w.dock_other_bands(&[]);+ self.others_told.clear();+ }+ }+/// The dock was told to let go: when it has - and the work area shows that Explorer took the removal - the work areas are set; when/// it takes too long it gets its band back and the try is made again after a pause.///@@ -930,6 +989,7 @@ impl Controller {return Err(format!("{bad} work area(s) could not be put back"));}}+ self.take_back_other_bands(w);// The dock registers its band with Explorer again only now: the taskbar is shown and the user's work areas are back, so// Explorer computes the band's place from them (registered earlier, the written-down rectangles would overrule it).if self.edge != Edge::Free {diff --git a/crates/rf-shellguard/src/tbedge_tests.rs b/crates/rf-shellguard/src/tbedge_tests.rsindex f694f0f3..928942bd 100644--- a/crates/rf-shellguard/src/tbedge_tests.rs+++ b/crates/rf-shellguard/src/tbedge_tests.rs@@ -886,3 +886,98 @@ fn single_monitor_parked_taskbar_recovers_lost_band_soon_and_then_at_most_once_plet answers = w.work_sets.len() - before;assert!((10..=16).contains(&answers), "{answers} answers in ten minutes");}++// ---------------------------------------------------------------- Explorer's own auto-hide: the bands are Explorer's to keep++/// The world of a host that turned Explorer's auto-hide on: the taskbar reserves no strip, the dock's band is registered with Explorer.+fn autohiding() -> (Controller, FakeWorld) {+ let (mut c, mut w) = world(true);+ w.autohides = true;+ w.monitors[0].work = [0, 0, 2560, 1440 - BAND];+ w.monitors[1].work = B;+ c.set_other_bands(&mut w, vec![("B".into(), BAND)]);+ (c, w)+}++#[test]+fn with_explorers_auto_hide_on_the_dock_keeps_its_band_with_explorer_and_no_work_area_is_ever_set() {+ let (mut c, mut w) = autohiding();+ on(&mut c, &mut w);+ assert_eq!(c.status(), Status::Hidden(2));+ assert_eq!(c.edge(), Edge::Free, "the edge is not taken: Explorer computes the work area from the dock's own band");+ assert_eq!(w.count("dock.take"), 0);+ assert_eq!(w.count("work:"), 0);+ assert_eq!(w.count("dock.others:B=78"), 1, "the dock on the other monitor registers its band with Explorer, too");+ // Explorer recomputes whenever it likes (its taskbar slid in and out, another program's toolbar came or went): nothing of ours is+ // lost by that, so nothing is answered - not at once, not after a minute+ for _ in 0..90 {+ w.now += 1_000;+ w.monitors[0].work = A;+ c.work_area_changed(&mut w);+ c.tick(&mut w);+ }+ assert_eq!(w.count("work:"), 0);+ assert_eq!(w.count("dock.take"), 0);+ assert_eq!(w.count("dock.others:"), 1, "said once, not at every look");+ assert!(w.state.original_work_areas().is_empty(), "nothing was changed, so nothing is written down to put back");+}++#[test]+fn an_edge_taken_before_the_auto_hide_came_on_is_given_back_to_explorer() {+ let (mut c, mut w) = settled();+ c.set_other_bands(&mut w, vec![("B".into(), BAND)]);+ w.calls.clear();+ w.autohides = true;+ w.now += 1_000;+ c.tick(&mut w);+ assert_eq!(c.edge(), Edge::Free);+ assert_eq!(w.count("dock.give"), 1, "the dock registers its band with Explorer again");+ assert_eq!(w.count("dock.others:B=78"), 1);+ assert!(w.state.original_work_areas().is_empty(), "the rectangles written down for the taken edge are not put back later");+ assert!(w.state.hidden_taskbar().is_some(), "the record of the hidden windows stays");+ let sets = w.count("work:");+ for _ in 0..10 {+ w.now += 1_000;+ c.tick(&mut w);+ }+ assert_eq!(w.count("dock.give"), 1);+ assert_eq!(w.count("work:"), sets);+}++#[test]+fn when_the_auto_hide_goes_off_the_other_docks_bands_come_back_and_the_edge_is_taken_as_before() {+ let (mut c, mut w) = autohiding();+ on(&mut c, &mut w);+ w.calls.clear();+ // the taskbar is a hidden one that keeps its strip again+ w.autohides = false;+ w.monitors[0].work = [0, 0, 2560, 1392 - BAND];+ w.monitors[1].work = [-1440, -200, 0, 2311];+ w.now += 1_000;+ c.tick(&mut w);+ in_order(&w, &["dock.others:", "dock.take:0,1362,2560,1440", "work:0,0,2560,1362"]);+ assert_eq!(w.calls.iter().find(|c| c.starts_with("dock.others:")).map(String::as_str), Some("dock.others:"), "an empty list: none");+ assert_eq!(c.edge(), Edge::Ours);+ assert_eq!(work_b(&w), [-1440, -200, 0, 2359 - BAND]);+}++#[test]+fn leaving_takes_the_other_docks_bands_back_from_explorer() {+ let (mut c, mut w) = autohiding();+ on(&mut c, &mut w);+ w.calls.clear();+ c.set_wanted(&mut w, false);+ assert_eq!(w.calls.iter().filter(|c| c.starts_with("dock.others:")).map(String::as_str).collect::<Vec<_>>(), ["dock.others:"]);+ assert_eq!(w.count("work:"), 0, "no work area was ours, so none is put back");+ assert_eq!(c.status(), Status::Off);+}++#[test]+fn a_changed_band_of_another_dock_is_told_again_while_explorer_keeps_the_bands() {+ let (mut c, mut w) = autohiding();+ on(&mut c, &mut w);+ c.set_other_bands(&mut w, vec![("B".into(), 30)]);+ assert_eq!(w.count("dock.others:B=30"), 1);+ c.set_other_bands(&mut w, vec![]);+ assert_eq!(w.calls.last().map(String::as_str), Some("dock.others:"));+}diff --git a/crates/rf-shellguard/src/tbfakes.rs b/crates/rf-shellguard/src/tbfakes.rsindex 4a319c58..18e4b696 100644--- a/crates/rf-shellguard/src/tbfakes.rs+++ b/crates/rf-shellguard/src/tbfakes.rs@@ -75,6 +75,9 @@ pub struct FakeWorld {/// the tray host): the band stays in the work area.pub explorer_keeps_band: bool,dock_looks: u32,+ /// Explorer's taskbar hides itself (its auto-hide is on): it reserves no strip, and a band registered with Explorer is kept by+ /// Explorer.+ pub autohides: bool,/// The band (thickness) the dock has registered with Explorer now: it is part of the primary monitor's work area.pub dock_band: Option<i32>,/// The band the dock registers again when it is given the edge back.@@ -121,6 +124,7 @@ impl FakeWorld {dock_stuck: false,explorer_keeps_band: false,dock_looks: 0,+ autohides: false,dock_band: None,dock_wants_band: None,monitors: vec![],@@ -164,6 +168,15 @@ impl FakeWorld {impl HideWorld for FakeWorld {fn any_fullscreen(&mut self) -> bool { self.fullscreen_active }+ fn explorer_keeps_bands(&mut self) -> bool {+ self.autohides+ }++ fn dock_other_bands(&mut self, bands: &[(String, i32)]) {+ let list: Vec<String> = bands.iter().map(|(id, t)| format!("{id}={t}")).collect();+ self.calls.push(format!("dock.others:{}", list.join(",")));+ }+fn now_ms(&mut self) -> u64 {self.now}diff --git a/crates/rf-win/src/dock/system.rs b/crates/rf-win/src/dock/system.rsindex e7be1016..57a2d769 100644--- a/crates/rf-win/src/dock/system.rs+++ b/crates/rf-win/src/dock/system.rs@@ -220,6 +220,57 @@ pub fn appbar_held() -> bool {/// The window that holds our toolbar registration right now (0: none). Read by the panic hook, which can run on any thread.static BAR_WINDOW: std::sync::atomic::AtomicIsize = std::sync::atomic::AtomicIsize::new(0);+// ---------------------------------------------------------------- the bands of the docks on the other monitors+//+// While Explorer's taskbar hides itself (`rf_shellguard::tbctl`, `explorer_keeps_bands`) the dock on every other monitor keeps a band+// of its own registered with Explorer, like the home dock's: Explorer then computes that monitor's work area itself and keeps it+// through every recomputation. A registration belongs to a window, so each of these bands has a hidden window of its own on the+// system thread; they tell the system window when Explorer moves them.++/// The bands wanted on the other monitors (device name, thickness in device px). Empty: none.+static OTHER_WANT: Mutex<Vec<(String, i32)>> = Mutex::new(Vec::new());+/// The windows that hold a registration for another monitor's band right now, for the panic hook.+static OTHER_BAR_WINDOWS: Mutex<Vec<isize>> = Mutex::new(Vec::new());++/// The docks on the other monitors keep these bands registered with Explorer (an empty list: none; the registrations are given+/// back). Does not wait: the system thread registers, moves and removes them. Costs a lock and a comparison when nothing changed.+pub fn set_other_bands(bands: Vec<(String, i32)>) {+ let changed = {+ let mut g = OTHER_WANT.lock().unwrap_or_else(|p| p.into_inner());+ let changed = *g != bands;+ *g = bands;+ changed+ };+ if changed {+ wake_system();+ }+}++fn other_want() -> Vec<(String, i32)> {+ OTHER_WANT.lock().unwrap_or_else(|p| p.into_inner()).clone()+}++/// One other monitor's band: its hidden window and its registration.+struct OtherBar {+ monitor: String,+ hwnd: isize,+ band: Band,+}++/// Which of the held bands go (their monitor is no longer wanted or no longer there) and which monitors need a new one. Pure, so that+/// the bookkeeping is a test: `held` and `present` are device names, `want` is the wish.+fn other_bands_plan(held: &[String], want: &[(String, i32)], present: &[String]) -> (Vec<String>, Vec<String>) {+ let wanted = |m: &String| want.iter().any(|(w, _)| w == m) && present.contains(m);+ let go: Vec<String> = held.iter().filter(|m| !wanted(m)).cloned().collect();+ let mut come: Vec<String> = Vec::new();+ for (m, _) in want {+ if present.contains(m) && !held.contains(m) && !come.contains(m) {+ come.push(m.clone());+ }+ }+ (go, come)+}+const WM_RESERVE: u32 = windows::Win32::UI::WindowsAndMessaging::WM_APP + 2;/// The message the system sends the toolbar's window about toolbars (`uCallbackMessage`).const WM_BAR: u32 = windows::Win32::UI::WindowsAndMessaging::WM_APP + 1;@@ -251,6 +302,8 @@ struct Ctx {tray_at_registration: Option<TrayId>,/// The edge state the app was last told about, so that taking or giving back the edge is announced once.edge_seen: (bool, Option<Rect>, Option<Rect>),+ /// The bands of the docks on the other monitors that are registered with Explorer (see [`set_other_bands`]).+ others: Vec<OtherBar>,}impl Ctx {@@ -288,6 +341,7 @@ impl DockSystem {layout_pending: false,tray_at_registration: None,edge_seen: (false, None, None),+ others: Vec::new(),});run(ctx, tx);let _ = end_tx.send(());@@ -393,6 +447,12 @@ fn remove_registered_bar() {let mut d = bar_data(windows::Win32::Foundation::HWND(h as *mut _));unsafe { windows::Win32::UI::Shell::SHAppBarMessage(windows::Win32::UI::Shell::ABM_REMOVE, &mut d) };}+ // (try_lock: the hook may run on the thread that holds the list)+ let others = OTHER_BAR_WINDOWS.try_lock().map(|mut g| std::mem::take(&mut *g)).unwrap_or_default();+ for h in others {+ let mut d = bar_data(windows::Win32::Foundation::HWND(h as *mut _));+ unsafe { windows::Win32::UI::Shell::SHAppBarMessage(windows::Win32::UI::Shell::ABM_REMOVE, &mut d) };+ }}/// The id of the broadcast message Explorer sends every top-level window when its taskbar is (re)created: after it crashed or was@@ -411,6 +471,27 @@ fn bar_data(hwnd: windows::Win32::Foundation::HWND) -> windows::Win32::UI::Shellstruct RealBar {hwnd: windows::Win32::Foundation::HWND,edge: DockEdge,+ /// The band of a dock on another monitor (its window is kept in the list of those, not as the home dock's).+ other: bool,+}++impl RealBar {+ fn home(hwnd: windows::Win32::Foundation::HWND, edge: DockEdge) -> RealBar {+ RealBar { hwnd, edge, other: false }+ }++ fn note(&self, held: bool) {+ let h = self.hwnd.0 as isize;+ if self.other {+ let mut g = OTHER_BAR_WINDOWS.lock().unwrap_or_else(|p| p.into_inner());+ g.retain(|x| *x != h);+ if held {+ g.push(h);+ }+ } else {+ BAR_WINDOW.store(if held { h } else { 0 }, Ordering::SeqCst);+ }+ }}impl AppBarCalls for RealBar {@@ -419,7 +500,7 @@ impl AppBarCalls for RealBar {if unsafe { windows::Win32::UI::Shell::SHAppBarMessage(windows::Win32::UI::Shell::ABM_NEW, &mut d) } == 0 {return false;}- BAR_WINDOW.store(self.hwnd.0 as isize, Ordering::SeqCst);+ self.note(true);true}@@ -430,7 +511,8 @@ impl AppBarCalls for RealBar {DockEdge::Right => windows::Win32::UI::Shell::ABE_RIGHT,};d.rc = windows::Win32::Foundation::RECT { left: edge.left, top: edge.top, right: edge.right, bottom: edge.bottom };- unsafe { windows::Win32::UI::Shell::SHAppBarMessage(windows::Win32::UI::Shell::ABM_QUERYPOS, &mut d) };+ let answer = unsafe { windows::Win32::UI::Shell::SHAppBarMessage(windows::Win32::UI::Shell::ABM_QUERYPOS, &mut d) };+ log::debug!("dock: band window {:#x} asked for {edge:?}, Explorer said {:?} (answer {answer})", self.hwnd.0 as isize, rect_of(d.rc));rect_of(d.rc)}@@ -441,13 +523,14 @@ impl AppBarCalls for RealBar {DockEdge::Right => windows::Win32::UI::Shell::ABE_RIGHT,};d.rc = windows::Win32::Foundation::RECT { left: rc.left, top: rc.top, right: rc.right, bottom: rc.bottom };- unsafe { windows::Win32::UI::Shell::SHAppBarMessage(windows::Win32::UI::Shell::ABM_SETPOS, &mut d) };+ let answer = unsafe { windows::Win32::UI::Shell::SHAppBarMessage(windows::Win32::UI::Shell::ABM_SETPOS, &mut d) };+ log::debug!("dock: band window {:#x} set to {rc:?}, Explorer made it {:?} (answer {answer})", self.hwnd.0 as isize, rect_of(d.rc));}fn remove(&mut self) {let mut d = bar_data(self.hwnd);unsafe { windows::Win32::UI::Shell::SHAppBarMessage(windows::Win32::UI::Shell::ABM_REMOVE, &mut d) };- BAR_WINDOW.store(0, Ordering::SeqCst);+ self.note(false);}}@@ -460,7 +543,7 @@ unsafe fn apply_reservation(hwnd: windows::Win32::Foundation::HWND, ctx: &mut Ct(if APPBAR_SUPPRESSED.load(Ordering::SeqCst) { None } else { shared.want }, shared.edge)};let view = primary_monitor().map(|m| (m.rect, m.work));- let applied = ctx.band.apply_on(&mut RealBar { hwnd, edge }, want, view, edge);+ let applied = ctx.band.apply_on(&mut RealBar::home(hwnd, edge), want, view, edge);APPBAR_HELD.store(ctx.band.registered(), Ordering::SeqCst);if !ctx.band.registered() {ctx.tray_at_registration = None;@@ -495,6 +578,88 @@ unsafe fn apply_reservation(hwnd: windows::Win32::Foundation::HWND, ctx: &mut Ct}Applied::Unchanged => {}}+ unsafe { apply_other_bands(hwnd, ctx, edge) };+}++/// Brings the bands of the docks on the other monitors in line with the wish ([`set_other_bands`]): a hidden window and a+/// registration for each wanted monitor that is there, none for the others. Called wherever the home band is looked at (the wish+/// changed, Explorer moved a toolbar, the screens changed, Explorer started again).+unsafe fn apply_other_bands(system: windows::Win32::Foundation::HWND, ctx: &mut Ctx, edge: DockEdge) {+ use windows::Win32::UI::WindowsAndMessaging::{DestroyWindow, SetTimer};+ // While the host owns the edges it sets these monitors' work areas itself: no band is registered.+ let want = if APPBAR_SUPPRESSED.load(Ordering::SeqCst) { Vec::new() } else { other_want() };+ if want.is_empty() && ctx.others.is_empty() {+ return;+ }+ let displays = super::monitors::displays();+ let present: Vec<String> = displays.iter().filter(|d| !d.primary).map(|d| d.name.clone()).collect();+ let held: Vec<String> = ctx.others.iter().map(|o| o.monitor.clone()).collect();+ let (go, come) = other_bands_plan(&held, &want, &present);+ for m in &go {+ if let Some(i) = ctx.others.iter().position(|o| o.monitor == *m) {+ let mut o = ctx.others.remove(i);+ let hwnd = windows::Win32::Foundation::HWND(o.hwnd as *mut _);+ o.band.apply(&mut RealBar { hwnd, edge, other: true }, None, None);+ unsafe {+ let _ = DestroyWindow(hwnd);+ }+ log::debug!("dock: the band on {m} is given back");+ }+ }+ for m in come {+ match unsafe { other_bar_window(system) } {+ Some(hwnd) => ctx.others.push(OtherBar { monitor: m, hwnd, band: Band::new() }),+ None => log::warn!("dock: no window for the band on {m}; that monitor's work area stays as it is"),+ }+ }+ let mut refused = false;+ for o in ctx.others.iter_mut() {+ let Some(thickness) = want.iter().find(|(m, _)| *m == o.monitor).map(|(_, t)| (*t).max(1)) else { continue };+ let Some(d) = displays.iter().find(|d| d.name == o.monitor) else { continue };+ let hwnd = windows::Win32::Foundation::HWND(o.hwnd as *mut _);+ match o.band.apply_on(&mut RealBar { hwnd, edge, other: true }, Some(thickness), Some((d.info.rect, d.info.work)), edge) {+ Applied::Set(granted) => log::debug!("dock: reserved {granted:?} on {}", o.monitor),+ Applied::RegisterFailed => refused = true,+ Applied::Released | Applied::Unchanged => {}+ }+ }+ if refused {+ unsafe { SetTimer(Some(system), TIMER_RETRY, RETRY_MS, None) };+ }+}++/// A hidden window for one other monitor's band. Its only work is to pass Explorer's toolbar notifications on to the system window,+/// which looks at every band then.+unsafe fn other_bar_window(system: windows::Win32::Foundation::HWND) -> Option<isize> {+ use windows::Win32::System::LibraryLoader::GetModuleHandleW;+ use windows::Win32::UI::WindowsAndMessaging::{CreateWindowExW, GWLP_USERDATA, RegisterClassExW, SetWindowLongPtrW, WNDCLASSEXW, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_POPUP};+ use windows::core::w;+ unsafe {+ let hinst = GetModuleHandleW(None).ok()?;+ let class = w!("RustyfilesDockBand");+ let wc = WNDCLASSEXW { cbSize: size_of::<WNDCLASSEXW>() as u32, lpfnWndProc: Some(other_bar_proc), hInstance: hinst.into(), lpszClassName: class, ..Default::default() };+ // (registered again for every window: that failing the second time is fine)+ RegisterClassExW(&wc);+ let hwnd = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE, class, w!(""), WS_POPUP, 0, 0, 0, 0, None, None, Some(hinst.into()), None).ok()?;+ SetWindowLongPtrW(hwnd, GWLP_USERDATA, system.0 as isize);+ Some(hwnd.0 as isize)+ }+}++unsafe extern "system" fn other_bar_proc(hwnd: windows::Win32::Foundation::HWND, msg: u32, wp: windows::Win32::Foundation::WPARAM, lp: windows::Win32::Foundation::LPARAM) -> windows::Win32::Foundation::LRESULT {+ use windows::Win32::Foundation::{HWND, LPARAM, LRESULT, WPARAM};+ use windows::Win32::UI::WindowsAndMessaging::{DefWindowProcW, GWLP_USERDATA, GetWindowLongPtrW, PostMessageW};+ unsafe {+ // ABN_STATECHANGE 0, ABN_POSCHANGED 1: the taskbar or another toolbar changed. Posted, not sent: Explorer waits for this answer.+ if msg == WM_BAR && wp.0 <= 1 {+ let system = GetWindowLongPtrW(hwnd, GWLP_USERDATA);+ if system != 0 {+ let _ = PostMessageW(Some(HWND(system as *mut _)), WM_RESERVE, WPARAM(0), LPARAM(0));+ }+ return LRESULT(0);+ }+ DefWindowProcW(hwnd, msg, wp, lp)+ }}/// Explorer's own taskbar window right now (the one of class `Shell_TrayWnd` that Explorer owns): handle, owner, the owner's start@@ -581,7 +746,12 @@ unsafe extern "system" fn wndproc(hwnd: windows::Win32::Foundation::HWND, msg: uSetWindowLongPtrW(hwnd, GWLP_USERDATA, 0);// (the band is given back: want None)SYSTEM_WINDOW.store(0, Ordering::SeqCst);- ctx.band.apply(&mut RealBar { hwnd, edge: DockEdge::Bottom }, None, None);+ ctx.band.apply(&mut RealBar::home(hwnd, DockEdge::Bottom), None, None);+ for mut o in std::mem::take(&mut ctx.others) {+ let other = windows::Win32::Foundation::HWND(o.hwnd as *mut _);+ o.band.apply(&mut RealBar { hwnd: other, edge: DockEdge::Bottom, other: true }, None, None);+ let _ = DestroyWindow(other);+ }APPBAR_HELD.store(false, Ordering::SeqCst);ctx.shared().band = None;drop(ctx);@@ -607,6 +777,9 @@ unsafe extern "system" fn wndproc(hwnd: windows::Win32::Foundation::HWND, msg: ulet restart = announcement_is_restart(registered, ctx.tray_at_registration, if registered { explorer_tray_id() } else { None });if restart {ctx.band.announced();+ for o in ctx.others.iter_mut() {+ o.band.announced();+ }ctx.tray_at_registration = None;ctx.register_tries = 0;ctx.shared().band = None;@@ -726,7 +899,11 @@ unsafe extern "system" fn wndproc(hwnd: windows::Win32::Foundation::HWND, msg: uif wp.0 != 0 {// (written to the log so that a dock that ends with the session says why)log::warn!("shell host exits: the session is ending");- ctx.band.apply(&mut RealBar { hwnd, edge: DockEdge::Bottom }, None, None);+ ctx.band.apply(&mut RealBar::home(hwnd, DockEdge::Bottom), None, None);+ for o in ctx.others.iter_mut() {+ let other = windows::Win32::Foundation::HWND(o.hwnd as *mut _);+ o.band.apply(&mut RealBar { hwnd: other, edge: DockEdge::Bottom, other: true }, None, None);+ }}LRESULT(0)}@@ -781,6 +958,25 @@ mod tests {assert!(!appbar_held());}+ #[test]+ fn the_bands_on_other_monitors_come_for_wanted_monitors_that_are_there_and_go_for_the_rest() {+ let n = |s: &str| s.to_string();+ let want = vec![(n("B"), 48), (n("C"), 48)];+ // nothing held yet: one for each wanted monitor that is plugged in+ assert_eq!(other_bands_plan(&[], &want, &[n("B"), n("C")]), (vec![], vec![n("B"), n("C")]));+ // a wanted monitor that is not there gets none+ assert_eq!(other_bands_plan(&[], &want, &[n("B")]), (vec![], vec![n("B")]));+ // held and still wanted: nothing to do+ assert_eq!(other_bands_plan(&[n("B"), n("C")], &want, &[n("B"), n("C")]), (vec![], vec![]));+ // a monitor that was unplugged, and one that is no longer wanted, give theirs back+ assert_eq!(other_bands_plan(&[n("B"), n("C")], &want, &[n("B")]), (vec![n("C")], vec![]));+ assert_eq!(other_bands_plan(&[n("B"), n("C")], &[(n("C"), 30)], &[n("B"), n("C")]), (vec![n("B")], vec![]));+ // the wish emptied: all go+ assert_eq!(other_bands_plan(&[n("B")], &[], &[n("B")]), (vec![n("B")], vec![]));+ // a monitor named twice in the wish gets one band+ assert_eq!(other_bands_plan(&[], &[(n("B"), 48), (n("B"), 30)], &[n("B")]), (vec![], vec![n("B")]));+ }+#[test]fn events_are_comparable_and_small() {assert_eq!(SystemEvent::Fullscreen(true), SystemEvent::Fullscreen(true));diff --git a/crates/rf-win/src/taskbar_hide.rs b/crates/rf-win/src/taskbar_hide.rsindex 6de52fde..8eea30dc 100644--- a/crates/rf-win/src/taskbar_hide.rs+++ b/crates/rf-win/src/taskbar_hide.rs@@ -118,11 +118,13 @@ struct RealWorld {child: Option<Child>,ready: Option<isize>,done: Option<isize>,+ /// Whether Explorer's taskbar hides itself, as last asked, and when.+ autohides: Option<(std::time::Instant, bool)>,}impl RealWorld {fn new(cfg: Config) -> RealWorld {- RealWorld { cfg, host_pid: std::process::id(), child: None, ready: None, done: None }+ RealWorld { cfg, host_pid: std::process::id(), child: None, ready: None, done: None, autohides: None }}fn state_path(&self) -> PathBuf {@@ -204,6 +206,23 @@ impl HideWorld for RealWorld {crate::dock::system::give_back_edge();}+ fn explorer_keeps_bands(&mut self) -> bool {+ // (a message to Explorer: asked at most twice a second, the edge is looked at more often than that)+ let now = std::time::Instant::now();+ if let Some((at, on)) = self.autohides+ && now.duration_since(at) < Duration::from_millis(500)+ {+ return on;+ }+ let on = crate::taskbar_autohide::get() == Some(true);+ self.autohides = Some((now, on));+ on+ }++ fn dock_other_bands(&mut self, bands: &[(String, i32)]) {+ crate::dock::system::set_other_bands(bands.to_vec());+ }+fn any_fullscreen(&mut self) -> bool {self.monitors().into_iter().any(|m| {let [l, t, r, b] = m.rect;diff --git a/docs/design/taskbar-hide.md b/docs/design/taskbar-hide.mdindex c328007e..5ce98513 100644--- a/docs/design/taskbar-hide.md+++ b/docs/design/taskbar-hide.md@@ -20,10 +20,12 @@ calls are listed under "What was not run".`Shell_SecondaryTrayWnd` (one per other monitor), with `SetWindowPos(SWP_HIDEWINDOW)` and nothing else in the flags that moves, sizes,reorders or activates. Only windows that were VISIBLE are hidden, and only those are ever shown again: a taskbar that something elsehid before stays as it was found.-* **Not changed:** the taskbar's auto-hide state (`ABM_SETSTATE`), any other taskbar setting, any registry value, any Windows setting.- Why not auto-hide: other bars use it as a first step (ManagedShell sets it, then hides), but it writes the user's taskbar settings- (`StuckRects3`), and nobody could show that it is undone on EVERY path (a power cut after the call included). Visibility is- process-local state of Explorer's windows: it ends with the Explorer process, and a new Explorer shows its taskbar as always.+* **Changed since 1.0.7:** the taskbar's auto-hide (`ABM_SETSTATE`, `rf_win::taskbar_autohide`): turned on while the hide is wanted,+ so that the taskbar is out of sight at the next sign-in before rustyfiles has started. The user's own value is noted first+ (`taskbar-autohide-before` in the settings folder) and put back when the hide is turned off, the Dock is stopped, or rustyfiles is+ uninstalled. This is what decides who keeps the dock's band: see "When Explorer's taskbar hides itself".+* **Not changed:** any other taskbar setting, any registry value, any other Windows setting. Visibility is process-local state of+ Explorer's windows: it ends with the Explorer process, and a new Explorer shows its taskbar as always.* **The Start button window (class atom 0xC017)** of the Windows 10 taskbar is not hidden: on Windows 11 the taskbar is one XAMLisland inside `Shell_TrayWnd`; hiding the outer window hides it.* **The work area:** the running session's, while the hide is in force: see "The strip the taskbar reserved". Never stored (no@@ -256,6 +258,33 @@ the hide is in force (`EnumDisplayMonitors`, a few small calls), one `EnumWindowThe probe prints what the rule WOULD do on this machine with a 78 px band and with none (run it before anything else).+## When Explorer's taskbar hides itself: the bands stay Explorer's++Everything in the section above is for a hidden taskbar that KEEPS its strip. Since 1.0.7 the taskbar also auto-hides, and an+auto-hiding taskbar reserves nothing. Holding the work area ourselves was then not only unnecessary, it could not last:++* Explorer computes every monitor's work area from its own list of toolbars, and it does so again whenever its taskbar slides in or+ out, when any program's toolbar comes or goes, when a display changes. A rectangle set with `SPI_SETWORKAREA` is not in that list,+ so each recomputation wiped it. Measured on a real PC (2026-12-04, two monitors, 1.0.10): after a dock start the primary monitor's+ work area went back to the whole monitor five times in eight seconds, and each time stayed there until the growing pause of the+ answer was over (2, 4, 8 ... 60 s); another program registering or removing a toolbar wiped it again each time. Maximised windows+ reached under the dock for as long (issues 883, 888, 999).+* The second monitor was never set at all: its taskbar parks below the screen while it auto-hides, a parked secondary taskbar is+ deliberately not taken for ours (issue 777), so that monitor stayed "another toolbar's" and its dock stood over maximised windows.+* A toolbar band registered with Explorer on the same PC, in the same minutes, kept its monitor's work area through all of it,+ the dock's stop and start included.++So while Explorer's taskbar hides itself (`HideWorld::explorer_keeps_bands`, `ABM_GETSTATE`) the edge is NOT taken:++* the home dock keeps its own desktop-toolbar registration (`rf_win::dock::band`), exactly as when the taskbar is not hidden;+* the dock on every other monitor registers a band of its own (`rf_win::dock::system::set_other_bands`: one hidden window and one+ registration for each such monitor, on the dock's system thread);+* the controller sets no work area and writes none down: there is nothing of ours for Explorer to take back, and nothing to put+ back on the way out. An edge that was taken before the auto-hide came on is given back at the next look.++When the auto-hide is off (it could not be turned on, or the user's Explorer refuses it) the rules of the section above apply+unchanged, and the other docks give their registrations back first.+## Read-only probe`cargo run --offline -p rf-shellguard --example taskbar_probe` prints the monitors (rectangle and work area), the taskbar-class