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.

Win+E: the file manager takes it when the switched-on Dock is gone

gelenmedya34862c8c3096
diff --git a/crates/rf-app/src/shell/keylayer.rs b/crates/rf-app/src/shell/keylayer.rs
index 86695cc9..4c906be9 100644
--- a/crates/rf-app/src/shell/keylayer.rs
+++ b/crates/rf-app/src/shell/keylayer.rs
@@ -334,6 +334,17 @@ pub fn win_e_wanted(role: Role, default_fm: bool, dock_enabled: bool) -> bool {
default_fm && (role == Role::Dock || !dock_enabled)
}
+/// The file manager's process: whether the dock it leaves Win+E to answers on its pipe (read by [`watch`] every few seconds, off the
+/// UI thread). True until the first look, so a dock still starting is not raced for the key. Why (Discord, 2026-12-01): with the
+/// Dock switched on in Settings but its process gone (its windows closed), the file manager left Win+E to it and no one took the
+/// key, so Win+E opened File Explorer and the log had no "keys:" line at all.
+static DOCK_ANSWERS: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(true);
+
+/// The dock setting as the file manager's process acts on it: on only while a dock answers too.
+fn dock_in_charge(role: Role, dock_enabled: bool, dock_answers: bool) -> bool {
+ dock_enabled && (role == Role::Dock || dock_answers)
+}
+
/// The settings file was (re)read, or the host started: brings the layer in line with the two settings. Cheap when nothing changed.
pub fn on_settings(cx: &mut App) {
apply(cx, Role::Dock);
@@ -354,7 +365,14 @@ pub fn watch(cx: &mut App, role: Role) {
loop {
cx.background_executor().timer(Duration::from_secs(4)).await;
let now = cx.update(|cx| (rf_win::default_fm::is_enabled(rf_win::default_fm::CLASSES), cx.try_global::<Settings>().is_some_and(|s| s.dock_enabled)));
- if last.is_some_and(|l| l != now) {
+ // (the file manager's process also asks whether the dock it would leave Win+E to is there at all)
+ let answers = if role == Role::Main && now.1 { cx.background_executor().spawn(async { crate::dock::control::is_running() }).await } else { true };
+ let was = DOCK_ANSWERS.swap(answers, std::sync::atomic::Ordering::Relaxed);
+ if role == Role::Main && now.0 && now.1 && was != answers {
+ log::info!("keys: the dock {}", if answers { "answers again: Win+E is left to it" } else { "does not answer: the file manager takes Win+E" });
+ }
+ let now = (now.0, now.1, answers);
+ if last.is_some_and(|l| l != now) || was != answers {
cx.update(|cx| apply(cx, role));
}
last = Some(now);
@@ -369,7 +387,7 @@ fn apply(cx: &mut App, role: Role) {
Role::Dock => cx.try_global::<Settings>().map_or((false, false), wanted),
Role::Main => (false, false),
};
- let dock_enabled = cx.try_global::<Settings>().is_some_and(|s| s.dock_enabled);
+ let dock_enabled = dock_in_charge(role, cx.try_global::<Settings>().is_some_and(|s| s.dock_enabled), DOCK_ANSWERS.load(std::sync::atomic::Ordering::Relaxed));
let win_e = win_e_wanted(role, rf_win::default_fm::is_enabled(rf_win::default_fm::CLASSES), dock_enabled);
if !win && !alt && !win_e {
stop_because(cx, "both settings are off");
@@ -496,6 +514,10 @@ mod win_e_tests {
assert!(win_e_wanted(Role::Dock, true, true), "the dock runs: the dock takes it");
assert!(!win_e_wanted(Role::Main, true, true), "... and the file manager leaves it to the dock");
assert!(win_e_wanted(Role::Main, true, false), "no dock: the file manager takes it");
+ // the Dock switched on but its process gone: the file manager acts as if there were none
+ assert!(!super::dock_in_charge(Role::Main, true, false) && super::dock_in_charge(Role::Main, true, true));
+ assert!(super::dock_in_charge(Role::Dock, true, false), "the dock itself never waits for itself");
+ assert!(!super::dock_in_charge(Role::Main, false, true));
}
}