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.

Merge branch 'pr829' into pr-land

gelenmedya6c569839648d
diff --cc crates/rf-app/src/workspace.rs
index 42adc7a3,714908fc..39566e10
--- a/crates/rf-app/src/workspace.rs
+++ b/crates/rf-app/src/workspace.rs
@@@ -5752,12 -5732,20 +5752,27 @@@ fn rail_peek_width(full: f32, shown: f3
(RAIL_W + (full - RAIL_W) * shown).max(RAIL_W)
}
+/// Whether a colour sampled off the screen behind the rail matches this window's theme.
+/// When a file dialog opens over an app of the opposite theme and the pointer is already over the rail
+/// before DWM finishes presenting the dialog, `screen_color` can read the caller app behind it (issue 851).
+fn rail_peek_color_matches(c: Hsla, dark: bool) -> bool {
+ if dark { c.l < 0.45 } else { c.l > 0.55 }
+}
++
+ /// How far the floating sidebar (`rail-peek`) extends past the rail over the content area.
+ fn rail_peek_overlap(full: f32, shown: f32) -> f32 {
+ (rail_peek_width(full, shown) - RAIL_W).max(0.)
+ }
+
+ /// Background of the floating sidebar (`rail-peek`): over HyperGlass it keeps `content_bg`'s surface wash so the glass shows through;
+ /// over Mica / Solid it stays opaque (`sampled` from the rail, or opaque `content_bg`) so the content underneath does not bleed through.
+ fn rail_peek_bg_color(glass_on: bool, sampled: Option<Hsla>, content_bg: Hsla) -> Hsla {
+ if glass_on {
+ content_bg
+ } else {
+ sampled.unwrap_or(Hsla { a: 1., ..content_bg })
+ }
+ }
const RAIL_SNAP: f32 = 120.;
const SIDEBAR_MAX: f32 = 420.;
const PREVIEW_MIN: f32 = 220.;
@@@ -6622,7 -6606,7 +6638,7 @@@ impl Render for Workspace
.w(px(full_w))
// (the sidebar inside keeps its full width while the panel's own width moves: nothing in it is laid out anew)
.overflow_hidden()
- .bg(self.rail_peek_bg.filter(|c| rail_peek_color_matches(*c, p.dark)).unwrap_or(Hsla { a: 1., ..p.content_bg }))
- .bg(rail_peek_bg_color(glass_on, self.rail_peek_bg, p.content_bg))
++ .bg(rail_peek_bg_color(glass_on, self.rail_peek_bg.filter(|c| rail_peek_color_matches(*c, p.dark)), p.content_bg))
.border_r_1()
.border_color(p.border)
.rounded_r(theme::RADIUS)
@@@ -7440,8 -7460,7 +7495,8 @@@ mod launch_tests
#[cfg(test)]
mod rail_peek_tests {
- use super::{RAIL_W, rail_peek_color_matches, rail_peek_width};
- use super::{RAIL_W, rail_peek_bg_color, rail_peek_overlap, rail_peek_width};
++ use super::{RAIL_W, rail_peek_bg_color, rail_peek_color_matches, rail_peek_overlap, rail_peek_width};
+ use gpui_kit::Hsla;
/// The sidebar that comes out of the rail: from the rail's own width to the full one, a little past it while the spring swings,
/// and never narrower than the rail.
@@@ -7454,20 -7473,32 +7509,47 @@@
assert!(rail_peek_width(240.0, 0.5) > RAIL_W && rail_peek_width(240.0, 0.5) < 240.0);
}
+ #[test]
+ fn sampled_rail_color_must_match_theme_polarity() {
+ let dark_mica = Hsla::from(gpui_kit::rgb(0x202228));
+ let light_app = Hsla::from(gpui_kit::rgb(0xf3f3f3));
+ let mid_grey = Hsla::from(gpui_kit::rgb(0x808080));
+
+ assert!(rail_peek_color_matches(dark_mica, true));
+ assert!(!rail_peek_color_matches(light_app, true));
+ assert!(!rail_peek_color_matches(mid_grey, true));
+
+ assert!(rail_peek_color_matches(light_app, false));
+ assert!(!rail_peek_color_matches(dark_mica, false));
+ assert!(!rail_peek_color_matches(mid_grey, false));
+ }
++
+ #[test]
+ fn rail_peek_uses_glass_wash_over_hyperglass_and_opaque_over_other_backdrops() {
+ let mut content_bg: gpui_kit::Hsla = gpui_kit::rgb(0x141414).into();
+ content_bg.a = 0.22;
+ let sampled: gpui_kit::Hsla = gpui_kit::rgb(0x2A3B4C).into();
+
+ // Over HyperGlass: keeps content_bg's translucent surface wash even if a stale sampled color was present.
+ assert_eq!(rail_peek_bg_color(true, None, content_bg), content_bg);
+ assert_eq!(rail_peek_bg_color(true, Some(sampled), content_bg), content_bg);
+
+ // Over Mica / Solid: uses the sampled rail color when available, or opaque content_bg otherwise.
+ assert_eq!(rail_peek_bg_color(false, Some(sampled), content_bg), sampled);
+ let fallback = rail_peek_bg_color(false, None, content_bg);
+ assert_eq!(fallback.a, 1.0);
+ assert_eq!(fallback.h, content_bg.h);
+ assert_eq!(fallback.s, content_bg.s);
+ assert_eq!(fallback.l, content_bg.l);
+ }
+
+ #[test]
+ fn rail_peek_overlap_matches_extension_beyond_rail() {
+ assert_eq!(rail_peek_overlap(240.0, 0.0), 0.0);
+ assert_eq!(rail_peek_overlap(240.0, -0.2), 0.0);
+ assert_eq!(rail_peek_overlap(240.0, 1.0), 240.0 - RAIL_W);
+ assert_eq!(rail_peek_overlap(240.0, 0.5), rail_peek_width(240.0, 0.5) - RAIL_W);
+ }
}
/// The stops of Tab in a window, in order.