Skip to content

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.

Speed comparison: RF_BENCH_ORIGIN puts its windows on another monitor

gelenmedya00dc4dfdd862
diff --git a/crates/rf-win/src/bench.rs b/crates/rf-win/src/bench.rs
index c423198b..f83dd679 100644
--- a/crates/rf-win/src/bench.rs
+++ b/crates/rf-win/src/bench.rs
@@ -486,7 +486,8 @@ pub fn measure_launch(app: &App, arg: &std::ffi::OsStr, title: &str, quiet: Dura
let window_ms = t0.elapsed().as_secs_f64() * 1000.0;
let h = hwnd(win.hwnd);
unsafe {
- let _ = MoveWindow(h, 80, 80, SIZE.0, SIZE.1, true);
+ let (x, y) = origin();
+ let _ = MoveWindow(h, x, y, SIZE.0, SIZE.1, true);
// On top of everything, without taking the focus: Windows opens a window started from
// the background behind the active one, and some apps draw less (or not at all) while
// covered, which would skew the comparison. Every app is measured visible.
@@ -772,12 +773,25 @@ pub fn windows_of(pid: u32) -> Vec<(isize, String)> {
windows().into_iter().filter(|w| w.pid == pid).map(|w| (w.hwnd, w.title)).collect()
}
+/// Where measured windows go (screen pixels): 80,80, or `RF_BENCH_ORIGIN=x,y` to put them on another monitor, so the main one stays
+/// free for whoever sits at the computer while a long comparison runs.
+fn origin() -> (i32, i32) {
+ std::env::var("RF_BENCH_ORIGIN")
+ .ok()
+ .and_then(|v| {
+ let (x, y) = v.split_once(',')?;
+ Some((x.trim().parse().ok()?, y.trim().parse().ok()?))
+ })
+ .unwrap_or((80, 80))
+}
+
/// Puts a window on top at the measuring size without taking the focus (as [`measure_launch`]
/// does for the windows it opens).
pub fn place_on_top(hwnd_raw: isize) {
use windows::Win32::UI::WindowsAndMessaging::{HWND_TOPMOST, SWP_NOACTIVATE, SWP_SHOWWINDOW, SetWindowPos};
unsafe {
- let _ = SetWindowPos(hwnd(hwnd_raw), Some(HWND_TOPMOST), 80, 80, SIZE.0, SIZE.1, SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ let (x, y) = origin();
+ let _ = SetWindowPos(hwnd(hwnd_raw), Some(HWND_TOPMOST), x, y, SIZE.0, SIZE.1, SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
}