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
Picker: stay above an always-on-top owner (Prism's Download File dialog)
fixef94c40d59d1
diff --git a/crates/rf-app/src/picker.rs b/crates/rf-app/src/picker.rsindex 8c841987..1e64847b 100644--- a/crates/rf-app/src/picker.rs+++ b/crates/rf-app/src/picker.rs@@ -351,6 +351,12 @@ fn open_window(pipe: File, req: Request, cx: &mut App) {// stays above the app that asked, like its own dialog wouldrf_win::window::set_owner(hwnd, owner);}+ if owner != 0 && rf_win::window::owner_chain_topmost(owner) {+ // the app's window is "always on top" (Prism's Download File dialog): a normal window, however far forward, stays under+ // it. Windows' own dialog would be topmost with its owner, so ours is too (it goes away with the picker).+ let _ = rf_win::window::set_topmost(hwnd, true);+ dialog_log("app picker: owner is always on top, picker made topmost");+ }rf_win::window::bring_to_front(hwnd);if owner != 0 {// setting the owner did not move us above it (see raise_above_owner)diff --git a/crates/rf-win/src/window.rs b/crates/rf-win/src/window.rsindex 110a3068..d5c0bda9 100644--- a/crates/rf-win/src/window.rs+++ b/crates/rf-win/src/window.rs@@ -206,11 +206,31 @@ pub fn set_owner(hwnd: isize, owner: isize) {pub fn raise_above_owner(hwnd: isize) {use windows::Win32::Foundation::HWND;use windows::Win32::UI::WindowsAndMessaging::{HWND_TOP, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE, SetWindowPos};+ // An owner that is "always on top" (Prism's Download File dialog, any pinned window) lies in the topmost band: HWND_TOP only+ // reaches the top of the normal band, under it. Windows' own dialog, created with that owner, is made topmost with it; ours+ // gets its owner afterwards, so it joins the topmost band here.+ let owner = owner_of(hwnd);+ let after = if owner != 0 && owner_chain_topmost(owner) { HWND_TOPMOST } else { HWND_TOP };unsafe {- let _ = SetWindowPos(HWND(hwnd as *mut _), Some(HWND_TOP), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);+ let _ = SetWindowPos(HWND(hwnd as *mut _), Some(after), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);}}+/// Whether `hwnd` or any window that owns it (up the chain) is "always on top".+pub fn owner_chain_topmost(hwnd: isize) -> bool {+ let mut h = hwnd;+ for _ in 0..16 {+ if h == 0 {+ return false;+ }+ if is_topmost(h) {+ return true;+ }+ h = owner_of(h);+ }+ false+}+/// Makes a window usable again (EnableWindow): a dialog disables its owner while it is open.pub fn enable(hwnd: isize) {use windows::Win32::Foundation::HWND;@@ -286,8 +306,12 @@ fn bring_to_front_inner(hwnd: isize, alt_tap: bool) {// no keyboard focus granted: at least on top of every other windowuse windows::Win32::UI::WindowsAndMessaging::{HWND_NOTOPMOST, HWND_TOPMOST, SWP_NOMOVE, SWP_NOSIZE, SWP_SHOWWINDOW, SetWindowPos};let flags = SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW;+ let was_topmost = is_topmost(hwnd);let _ = SetWindowPos(h, Some(HWND_TOPMOST), 0, 0, 0, 0, flags);- let _ = SetWindowPos(h, Some(HWND_NOTOPMOST), 0, 0, 0, 0, flags);+ // (a window that was topmost already, such as a picker above an always-on-top app, stays so)+ if !was_topmost {+ let _ = SetWindowPos(h, Some(HWND_NOTOPMOST), 0, 0, 0, 0, flags);+ }}}}