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
Dock tray keeps icons that programs re-add right after removing them
denfrya4c38afb1be8
diff --git a/crates/rf-win/src/trayhost/lifecycle.rs b/crates/rf-win/src/trayhost/lifecycle.rsindex a2fc0588..34e4b31f 100644--- a/crates/rf-win/src/trayhost/lifecycle.rs+++ b/crates/rf-win/src/trayhost/lifecycle.rs@@ -105,11 +105,7 @@ impl<W: TrayWindow, B: Broadcast> Lifecycle<W, B> {return TickWork::default();}self.ticks = self.ticks.wrapping_add(1);- let mut work = TickWork::default();- if !self.window.is_first() {- self.window.raise();- work.raised = true;- }+ let mut work = TickWork { raised: self.keep_first(), ..TickWork::default() };if self.ticks.is_multiple_of(MIRROR_EVERY) {self.window.mirror(explorer_tray);work.mirrored = true;@@ -118,6 +114,19 @@ impl<W: TrayWindow, B: Broadcast> Lifecycle<W, B> {work}+ /// Puts ours back in front of Explorer's when it is not the first `Shell_TrayWnd`; says whether it had to. Asked by the tick and+ /// after every request passed on to Explorer: Explorer raises its own window while it handles one, and a program that sends the+ /// next request at once (`NIM_DELETE` and then `NIM_ADD`, the way Electron and others answer `TaskbarCreated`) found Explorer's+ /// window first and talked past the host. The icon was Explorer's only and never showed in the dock (Discord, after the dock's+ /// switch was turned off and on).+ pub fn keep_first(&mut self) -> bool {+ if !self.started || self.window.is_first() {+ return false;+ }+ self.window.raise();+ true+ }+/// Explorer made its taskbar again (`TaskbarCreated` reached us): its window may be on top now, and its rectangles are new.pub fn on_taskbar_created(&mut self, explorer_tray: Option<isize>) {if !self.started {@@ -268,6 +277,23 @@ mod tests {assert!(l.tick(None) == TickWork::default(), "raised once, first now");}+ #[test]+ fn keeping_first_raises_only_a_started_window_that_lost_the_place() {+ let log = new_log();+ let (mut l, w) = make(&log, false);+ w.set_first(false);+ assert!(!l.keep_first(), "not started: nothing to keep in front");+ l.start(None).unwrap();+ log.lock().clear();+ w.set_first(true);+ assert!(!l.keep_first());+ assert!(log.lock().is_empty());+ w.set_first(false);+ assert!(l.keep_first());+ assert_eq!(*log.lock(), vec!["window raised"]);+ assert!(!l.keep_first(), "first again after the raise");+ }+#[test]fn mirror_and_sweep_follow_their_counts() {let log = new_log();diff --git a/crates/rf-win/src/trayhost/win.rs b/crates/rf-win/src/trayhost/win.rsindex e526cd63..e8c5bc80 100644--- a/crates/rf-win/src/trayhost/win.rs+++ b/crates/rf-win/src/trayhost/win.rs@@ -561,7 +561,14 @@ fn wndproc_inner(hwnd: HWND, msg: u32, wp: WPARAM, lp: LPARAM) -> LRESULT {}let (dw_data, cb, ptr) = unsafe { ((*cds).dwData, (*cds).cbData as usize, (*cds).lpData as *const u8) };let bytes: &[u8] = if cb == 0 || ptr.is_null() { &[] } else { unsafe { std::slice::from_raw_parts(ptr, cb) } };- LRESULT(core.on_copydata(dw_data, bytes, Raw { msg, wparam: wp.0, lparam: lp.0 }))+ let answer = core.on_copydata(dw_data, bytes, Raw { msg, wparam: wp.0, lparam: lp.0 });+ // Explorer had the request and raised its own window meanwhile: ours goes back in front BEFORE the sender gets its+ // answer, or its next call finds Explorer's window first (see `Lifecycle::keep_first`). The tick alone came too late.+ let raised = LIFE.with(|l| l.try_borrow_mut().ok().and_then(|mut g| g.as_mut().map(|life| life.keep_first()))).unwrap_or(false);+ if raised {+ bump(&core.shared.counters.raised);+ }+ LRESULT(answer)}WM_TIMER if wp.0 == TIMER_TICK => {tick();