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: make opening the dock right-click menu easier across all islands
NKrN20815f3906f95
diff --git a/crates/rf-app/src/dock/left.rs b/crates/rf-app/src/dock/left.rsindex 1279658f..1bb9a677 100644--- a/crates/rf-app/src/dock/left.rs+++ b/crates/rf-app/src/dock/left.rs@@ -173,14 +173,35 @@ impl LeftIsland {cx.notify();}- /// A right click at `at` (the window's logical px): on the island's empty glass it starts Task Manager; on the logo or the field it is- /// theirs and does nothing here.- fn right_click(&mut self, at: Point<Pixels>, cx: &mut Context<Self>) {+ /// Opens the dock's glass context menu anchored at the current cursor X position.+ fn open_glass_menu(&self, cx: &mut App) {+ let Some((x, _)) = rf_win::dock::panel::cursor() else { return };+ super::island_menu::open(+ super::island_menu::MenuRequest {+ kind: Kind::Left,+ spot: super::island_menu::Spot::Glass,+ mon: self.mon,+ offered: Vec::new(),+ tray: false,+ anchor_x: x as f32,+ glass: self.glass.clone(),+ },+ cx,+ );+ }++ /// A right click at `at` (the window's logical px): on the island's empty glass (or anywhere on the island with Shift held) it+ /// opens the dock's menu; on the logo or a pinned launcher without Shift it is theirs and does nothing here.+ fn right_click(&mut self, at: Point<Pixels>, shift: bool, cx: &mut Context<Self>) {// While the glass has grown into the Start panel this row is its bottom row, under the panel's own content: a right click on- // its empty glass is not a request for Task Manager.+ // its empty glass is not a request for the dock's menu.if super::grow_host::island_fade(self.mon, Kind::Left, cx).is_some() {return;}+ if shift {+ self.open_glass_menu(cx);+ return;+ }let k = super::host::size_on(self.mon, cx);let [ml, mt, ..] = super::host::insets_on(self.mon, Kind::Left, cx).margins;let point = ((f32::from(at.x) - ml) / k, (f32::from(at.y) - mt) / k);@@ -199,19 +220,7 @@ impl LeftIsland {super::empty::left_controls_secondary(self.search)};if super::empty::side_is_empty(self.wanted_length(cx), super::host::side_height_on(self.mon, cx), &controls, point) {- let Some((x, _)) = rf_win::dock::panel::cursor() else { return };- super::island_menu::open(- super::island_menu::MenuRequest {- kind: Kind::Left,- spot: super::island_menu::Spot::Glass,- mon: self.mon,- offered: Vec::new(),- tray: false,- anchor_x: x as f32,- glass: self.glass.clone(),- },- cx,- );+ self.open_glass_menu(cx);}}@@ -430,7 +439,11 @@ impl Render for LeftIsland {// when the Start panel is ours)// (a plain handler, NOT a listener of this view: opening the panel makes every left island draw again, and a view cannot be// updated from inside its own update; the first version did that and the dock ended with a panic on the first right click)- .on_mouse_up(MouseButton::Right, move |_, _, cx| {+ .on_mouse_up(MouseButton::Right, move |ev: &MouseUpEvent, _, cx| {+ // Shift+Right-click anywhere on the island opens the dock's own menu instead of Start's.+ if ev.modifiers.shift {+ return;+ }cx.stop_propagation();if own_start(cx) {super::panel::start_system_menu_on(mon, cx);@@ -491,6 +504,12 @@ impl Render for LeftIsland {super::actions::open_quick_search();}})+ // The search pill is a button (not a text input while Start is closed), so right-clicking it offers an easy+ // target for the dock's context menu without needing to aim at the narrow edge padding.+ .on_mouse_up(MouseButton::Right, cx.listener(|me, _, _, cx| {+ cx.stop_propagation();+ me.open_glass_menu(cx);+ }))}));// the picture at the left of the temperature and, when the display has room, the condition in words under it@@ -560,6 +579,9 @@ impl Render for LeftIsland {.child(face).on_click(move |_, _, _| super::actions::click_app_reporting(&for_click, rf_win::dock::foreground_root(), |_| {})).on_mouse_up(MouseButton::Right, move |ev: &MouseUpEvent, window, cx| {+ if ev.modifiers.shift {+ return;+ }cx.stop_propagation();let anchor_x = if super::host::vertical(cx) { (f32::from(window.bounds().origin.y) + f32::from(ev.position.y)) * window.scale_factor() } else { (f32::from(window.bounds().origin.x) + f32::from(ev.position.x)) * window.scale_factor() };super::app_menu::open(super::app_menu::MenuRequest { app: for_menu.clone(), icon: menu_pic.clone(), anchor_x, glass: glass.clone() }, cx);@@ -570,9 +592,10 @@ impl Render for LeftIsland {});super::host::island_box(pal, fallback, k)- // a right click on the glass between and around the controls: Windows' Task Manager (the controls are told from the glass- // by their boxes, `empty.rs::left_controls`, which mirror the row below: padding, logo, gap, field; change one, change both)- .on_mouse_up(MouseButton::Right, cx.listener(|me, ev: &MouseUpEvent, _, cx| me.right_click(ev.position, cx)))+ // a right click on the glass between and around the controls (or Shift+Right-click anywhere on the island): dock menu+ // (the controls are told from the glass by their boxes, `empty.rs::left_controls`, which mirror the row below: padding,+ // logo, gap, field; change one, change both)+ .on_mouse_up(MouseButton::Right, cx.listener(|me, ev: &MouseUpEvent, _, cx| me.right_click(ev.position, ev.modifiers.shift, cx))).child(h_flex().size_full().when(!vertical, |d| d.px(px(plan::SIDE_PAD * k))).when(vertical, |d| d.flex_col().py(px(plan::SIDE_PAD * k))).items_center().child(logo).children(search).children(weather).children(launchers))}}diff --git a/crates/rf-app/src/dock/middle.rs b/crates/rf-app/src/dock/middle.rsindex cffd482b..39667a43 100644--- a/crates/rf-app/src/dock/middle.rs+++ b/crates/rf-app/src/dock/middle.rs@@ -792,34 +792,42 @@ impl MiddleIsland {app_menu::open(app_menu::MenuRequest { app: app.clone(), icon: self.icon_for(ix, 18.0, cx), anchor_x, glass: self.glass.clone() }, cx);}- /// A right click anywhere in the dock's window at `at` (logical px of the window): on the empty glass - not on an icon, whose own- /// click is the app menu - the dock's menu (`island_menu`: Task Manager, the dock's quick switches).- fn row_right_click(&mut self, at: Point<Pixels>, cx: &mut Context<Self>) {+ /// A right click anywhere in the dock's window at `at` (logical px of the window): on the empty glass - or anywhere on the island+ /// with Shift held - opens the dock's menu (`island_menu`: Task Manager, the dock's quick switches). Without Shift, a click on an+ /// icon (or its running mark) opens that app's menu.+ fn row_right_click(&mut self, at: Point<Pixels>, shift: bool, cx: &mut Context<Self>) {let at = if host::vertical(cx) { point(at.y, at.x) } else { at };if self.right.row_up() || self.drag.is_some() {return;}- let k = host::size_on(self.mon, cx);- let point = (f32::from(at.x) / k, f32::from(at.y) / k);- // the running mark under an icon is outside the icon's element (so the icon's own handler did not hear this click) but it is- // the icon's: its menu- if let Some(ix) = super::empty::mark_owner(&self.last_icons, point) {- self.right_click(ix, cx);- } else if super::empty::middle_is_empty(self.last_glass, &self.last_icons, point) {+ let open_glass = |me: &Self, cx: &mut App| {let Some((x, y)) = rf_win::dock::panel::cursor() else { return };let x = if host::vertical(cx) { y } else { x };super::island_menu::open(super::island_menu::MenuRequest {kind: host::Kind::Middle,spot: super::island_menu::Spot::Glass,- mon: self.mon,+ mon: me.mon,offered: Vec::new(),tray: false,anchor_x: x as f32,- glass: self.glass.clone(),+ glass: me.glass.clone(),},cx,);+ };+ if shift {+ open_glass(self, cx);+ return;+ }+ let k = host::size_on(self.mon, cx);+ let point = (f32::from(at.x) / k, f32::from(at.y) / k);+ // the running mark under an icon is outside the icon's element (so the icon's own handler did not hear this click) but it is+ // the icon's: its menu+ if let Some(ix) = super::empty::mark_owner(&self.last_icons, point) {+ self.right_click(ix, cx);+ } else if super::empty::middle_is_empty(self.last_glass, &self.last_icons, point) {+ open_glass(self, cx);}}@@ -1529,7 +1537,13 @@ impl Render for MiddleIsland {})).on_drop(cx.listener(move |me, paths: &ExternalPaths, _, cx| me.files_dropped(ix, paths.paths().to_vec(), cx))).on_hover(cx.listener(move |me, on: &bool, _, cx| me.item_hover(ix, *on, cx)))- .on_mouse_up(MouseButton::Right, cx.listener(move |me, _, _, cx| me.right_click(ix, cx)))+ .on_mouse_up(MouseButton::Right, cx.listener(move |me, ev: &MouseUpEvent, _, cx| {+ // Shift+Right-click bubbles up to `row_right_click` to open the dock's own menu.+ if ev.modifiers.shift {+ return;+ }+ me.right_click(ix, cx);+ })).on_mouse_up(MouseButton::Middle, cx.listener(move |me, _, _, _| me.middle_click(ix))).on_scroll(cx.listener(move |me, ev: &ScrollEvent, _, cx| me.item_scrolled(ix, ev, cx))).into_any_element()@@ -1585,7 +1599,7 @@ impl Render for MiddleIsland {me.pointer_moved((f32::from(p) - host::insets_on(mon, Kind::Middle, cx).margins[margin]) / k, strength, ev.pressed_button.is_some(), cx)})).on_mouse_down(MouseButton::Right, cx.listener(|me, _, _, cx| me.right_down(cx)))- .on_mouse_up(MouseButton::Right, cx.listener(|me, ev: &MouseUpEvent, _, cx| me.row_right_click(ev.position, cx)))+ .on_mouse_up(MouseButton::Right, cx.listener(|me, ev: &MouseUpEvent, _, cx| me.row_right_click(ev.position, ev.modifiers.shift, cx))).on_mouse_down(MouseButton::Left, cx.listener(|me, _, _, _| me.pressed())).on_mouse_up(MouseButton::Left, cx.listener(|me, ev: &MouseUpEvent, _, cx| me.released_at(ev.position, cx))).on_mouse_up_out(MouseButton::Left, cx.listener(|me, ev: &MouseUpEvent, _, cx| me.released_at(ev.position, cx)))diff --git a/crates/rf-app/src/dock/right.rs b/crates/rf-app/src/dock/right.rsindex bc23bd2b..aaac18e1 100644--- a/crates/rf-app/src/dock/right.rs+++ b/crates/rf-app/src/dock/right.rs@@ -372,14 +372,20 @@ impl RightIsland {cx.notify();}- /// A right click at `at` (the window's logical px): the island's menu for what is there (`island_menu`): the empty glass, one of- /// the island's own symbols, the clock or the bell. A tray icon's right click is its program's, and the volume symbol's is the- /// list of output devices: nothing here.- fn right_click(&mut self, at: Point<Pixels>, cx: &mut Context<Self>) {- let Some(spot) = self.spot_at(at, cx) else { return };- if spot == super::island_menu::Spot::Status(Status::Volume) {- return;- }+ /// A right click at `at` (the window's logical px): the island's menu for what is there (`island_menu`): the empty glass (or+ /// anywhere on the island with Shift held, or a plain right click on the overflow chevron), one of the island's own symbols, the+ /// clock or the bell. Without Shift, a tray icon's right click is its program's, and the volume symbol's is the list of output+ /// devices: nothing here.+ fn right_click(&mut self, at: Point<Pixels>, shift: bool, cx: &mut Context<Self>) {+ let spot = if shift {+ super::island_menu::Spot::Glass+ } else {+ let Some(spot) = self.spot_at(at, true, cx) else { return };+ if spot == super::island_menu::Spot::Status(Status::Volume) {+ return;+ }+ spot+ };let Some((x, _)) = geo::cursor() else { return };let offered = if self.mon.is_home() { super::island_menu::offered(self.lang.layouts >= 2, super::sysstate::has_battery(cx)) } else { Vec::new() };let tray = self.mon.is_home() && super::tray_strip::shape(cx).is_some();@@ -389,14 +395,15 @@ impl RightIsland {/// A left press at `at`: the second of a double click on the empty glass shows the desktop (again: brings the windows back), as/// the island's menu says beside "Masaüstünü göster".fn left_down(&mut self, at: Point<Pixels>, clicks: usize, cx: &mut Context<Self>) {- if clicks == 2 && self.spot_at(at, cx) == Some(super::island_menu::Spot::Glass) {+ if clicks == 2 && self.spot_at(at, false, cx) == Some(super::island_menu::Spot::Glass) {crate::shell::keylayer::toggle_show_desktop();}}- /// What is at `at` (the window's logical px): the empty glass (the "Show desktop" strip counts as glass), one of the island's own- /// symbols, the clock or the bell. `None` off the glass and on a tray icon or the chevron.- fn spot_at(&self, at: Point<Pixels>, cx: &App) -> Option<super::island_menu::Spot> {+ /// What is at `at` (the window's logical px): the empty glass (the "Show desktop" strip counts as glass, and for a right click+ /// `for_menu = true` the tray overflow chevron counts as glass too), one of the island's own symbols, the clock or the bell.+ /// `None` off the glass and on a tray icon (and on the chevron for a left double click, so double-clicking it never minimizes windows).+ fn spot_at(&self, at: Point<Pixels>, for_menu: bool, cx: &App) -> Option<super::island_menu::Spot> {use super::island_menu::Spot;let k = super::host::size_on(self.mon, cx);let [ml, mt, ..] = super::host::insets_on(self.mon, Kind::Right, cx).margins;@@ -412,16 +419,11 @@ impl RightIsland {if !self.mon.is_home() {return Some(if hit == 0 { Spot::Clock } else { Spot::Bell });}- let cells = super::tray_strip::shape(cx).map_or(0, |s| s.visible + usize::from(s.chevron));+ let shape = super::tray_strip::shape(cx);+ let visible = shape.map_or(0, |s| s.visible);+ let has_chevron = shape.is_some_and(|s| s.chevron);let buttons = self.status_buttons(cx);- match hit.checked_sub(cells) {- None => None,- Some(i) if i < buttons.len() => Some(Spot::Status(buttons[i])),- Some(i) if i == buttons.len() => Some(Spot::Clock),- Some(i) if i == buttons.len() + 1 => Some(Spot::Bell),- // (the "Show desktop" strip)- Some(_) => Some(Spot::Glass),- }+ classify_home_hit(hit, visible, has_chevron, &buttons, for_menu)}/// The boxes of the island's controls, dock units from its glass's top left corner (`empty.rs`).@@ -823,8 +825,14 @@ impl Render for RightIsland {super::tray_tip::press(cx);me.status_down(which, e.click_count, cx)}))- // a right click on the volume symbol: the output devices, to choose from- .when(which == Status::Volume, |d| d.on_mouse_up(MouseButton::Right, |_, _, cx| open_output_devices(cx)))+ // a right click on the volume symbol: the output devices, to choose from (Shift+Right-click opens the dock menu instead)+ .when(which == Status::Volume, |d| {+ d.on_mouse_up(MouseButton::Right, |ev: &MouseUpEvent, _, cx| {+ if !ev.modifiers.shift {+ open_output_devices(cx);+ }+ })+ })// the wheel over it: the system's volume, as over Windows' own symbol (issue 136).when(which == Status::Volume, |d| d.on_scroll(cx.listener(|me, ev: &ScrollEvent, _, cx| me.volume_scrolled(ev, cx)))).child(button),@@ -847,10 +855,10 @@ impl Render for RightIsland {// (keys are listened to, and focus tracked, only while a strip is drawn)let focus = tray.is_some().then(|| self.focus.get_or_insert_with(|| cx.focus_handle()).clone());super::host::island_box(pal, fallback, k)- // a right click: the island's menu for what is under the pointer (`island_menu`; the controls are told from the glass- // by their boxes, `empty.rs::right_controls`, which mirror the row below in its order and distances: tray strip, the- // island's own buttons, separator, clock, bell; change one, change both)- .on_mouse_up(MouseButton::Right, cx.listener(|me, ev: &MouseUpEvent, _, cx| me.right_click(ev.position, cx)))+ // a right click: the island's menu for what is under the pointer (`island_menu`; Shift+Right-click always opens the full+ // glass menu; the controls are told from the glass by their boxes, `empty.rs::right_controls`, which mirror the row below+ // in its order and distances: tray strip, the island's own buttons, separator, clock, bell; change one, change both)+ .on_mouse_up(MouseButton::Right, cx.listener(|me, ev: &MouseUpEvent, _, cx| me.right_click(ev.position, ev.modifiers.shift, cx)))// a double click there: the desktop (`left_down`).on_mouse_down(MouseButton::Left, cx.listener(|me, ev: &MouseDownEvent, _, cx| me.left_down(ev.position, ev.click_count, cx))).when_some(focus, |d, focus| {@@ -895,6 +903,22 @@ impl Render for RightIsland {}}+/// Classifies a hit control index on the home right island into its menu spot.+/// The tray overflow chevron opens the full glass menu on right-click (`for_menu = true`) since it has no right-click action of its+/// own, while returning `None` for left double-clicks (`for_menu = false`) so rapidly toggling the overflow panel never triggers Show desktop.+fn classify_home_hit(hit: usize, visible_tray: usize, has_chevron: bool, buttons: &[Status], for_menu: bool) -> Option<super::island_menu::Spot> {+ use super::island_menu::Spot;+ let cells = visible_tray + usize::from(has_chevron);+ match hit.checked_sub(cells) {+ None => (for_menu && has_chevron && hit == visible_tray).then_some(Spot::Glass),+ Some(i) if i < buttons.len() => Some(Spot::Status(buttons[i])),+ Some(i) if i == buttons.len() => Some(Spot::Clock),+ Some(i) if i == buttons.len() + 1 => Some(Spot::Bell),+ // (the "Show desktop" strip)+ Some(_) => Some(Spot::Glass),+ }+}+#[cfg(test)]mod tests {#[test]@@ -906,4 +930,21 @@ mod tests {// a level between steps comes to the nearest step firstassert_eq!(super::volume_after_notches(0.411, 1), 0.44, "0.411 is taken as the step 0.42, one notch up");}++ #[test]+ fn tray_chevron_opens_glass_menu_on_right_click_but_not_double_click_show_desktop() {+ use super::Status;+ use super::super::island_menu::Spot;+ let buttons = [Status::Network, Status::Volume];+ // 2 visible tray icons (indices 0, 1) + chevron (index 2)+ assert_eq!(super::classify_home_hit(0, 2, true, &buttons, true), None, "tray icon keeps its own app menu");+ assert_eq!(super::classify_home_hit(1, 2, true, &buttons, true), None, "tray icon keeps its own app menu");+ assert_eq!(super::classify_home_hit(2, 2, true, &buttons, true), Some(Spot::Glass), "chevron right-click opens full dock menu");+ assert_eq!(super::classify_home_hit(2, 2, true, &buttons, false), None, "chevron double-click must not toggle show desktop");+ assert_eq!(super::classify_home_hit(3, 2, true, &buttons, true), Some(Spot::Status(Status::Network)));+ assert_eq!(super::classify_home_hit(4, 2, true, &buttons, true), Some(Spot::Status(Status::Volume)));+ assert_eq!(super::classify_home_hit(5, 2, true, &buttons, true), Some(Spot::Clock));+ assert_eq!(super::classify_home_hit(6, 2, true, &buttons, true), Some(Spot::Bell));+ assert_eq!(super::classify_home_hit(7, 2, true, &buttons, true), Some(Spot::Glass), "show desktop strip");+ }}diff --git a/crates/rf-app/src/dock/tray_strip.rs b/crates/rf-app/src/dock/tray_strip.rsindex 94318c6d..21d0dba5 100644--- a/crates/rf-app/src/dock/tray_strip.rs+++ b/crates/rf-app/src/dock/tray_strip.rs@@ -583,7 +583,14 @@ fn picture_of(st: &TrayState, i: usize, size: f32, scale: f32, pal: Palette) ->pub fn wire(cell: Stateful<Div>, src: Source) -> Stateful<Div> {cell.on_hover(move |on: &bool, _, cx| hover(src, *on, cx)).on_mouse_down(MouseButton::Left, move |e: &MouseDownEvent, _, cx| press(src, PointerButton::Left, e.click_count, cx))- .on_mouse_down(MouseButton::Right, move |e: &MouseDownEvent, _, cx| press(src, PointerButton::Right, e.click_count, cx))+ .on_mouse_down(MouseButton::Right, move |e: &MouseDownEvent, _, cx| {+ // Right-clicking the overflow chevron (or Shift+Right-clicking any tray icon) is handled by the right island to open the+ // dock's own menu rather than swallowed here.+ if src == Source::Chevron || e.modifiers.shift {+ return;+ }+ press(src, PointerButton::Right, e.click_count, cx);+ }).on_mouse_down(MouseButton::Middle, move |e: &MouseDownEvent, _, cx| press(src, PointerButton::Middle, e.click_count, cx))}