diff --git a/crates/editor2/src/element.rs b/crates/editor2/src/element.rs index 7fc5244b92758024d8cf5df8afeca54d29d81d68..8031bc5db60923b2470f723035c4df801cdd164e 100644 --- a/crates/editor2/src/element.rs +++ b/crates/editor2/src/element.rs @@ -884,7 +884,11 @@ impl EditorElement { bounds: text_bounds, }), |cx| { - if text_bounds.contains(&cx.mouse_position()) { + let interactive_text_bounds = InteractiveBounds { + bounds: text_bounds, + stacking_order: cx.stacking_order().clone(), + }; + if interactive_text_bounds.visibly_contains(&cx.mouse_position(), cx) { if self .editor .read(cx) @@ -1361,8 +1365,12 @@ impl EditorElement { )); } + let interactive_track_bounds = InteractiveBounds { + bounds: track_bounds, + stacking_order: cx.stacking_order().clone(), + }; let mut mouse_position = cx.mouse_position(); - if track_bounds.contains(&mouse_position) { + if interactive_track_bounds.visibly_contains(&mouse_position, cx) { cx.set_cursor_style(CursorStyle::Arrow); } @@ -1392,7 +1400,7 @@ impl EditorElement { cx.stop_propagation(); } else { editor.scroll_manager.set_is_dragging_scrollbar(false, cx); - if track_bounds.contains(&event.position) { + if interactive_track_bounds.visibly_contains(&event.position, cx) { editor.scroll_manager.show_scrollbar(cx); } } diff --git a/crates/gpui2/src/elements/text.rs b/crates/gpui2/src/elements/text.rs index 175a79c19a512832c7c70571780adb6268b91ab2..7716d81536117a6213133db7cdf8377f94f1f647 100644 --- a/crates/gpui2/src/elements/text.rs +++ b/crates/gpui2/src/elements/text.rs @@ -358,14 +358,13 @@ impl Element for InteractiveText { fn paint(&mut self, bounds: Bounds, state: &mut Self::State, cx: &mut WindowContext) { if let Some(click_listener) = self.click_listener.take() { - if let Some(ix) = state - .text_state - .index_for_position(bounds, cx.mouse_position()) - { + let mouse_position = cx.mouse_position(); + if let Some(ix) = state.text_state.index_for_position(bounds, mouse_position) { if self .clickable_ranges .iter() .any(|range| range.contains(&ix)) + && cx.was_top_layer(&mouse_position, cx.stacking_order()) { cx.set_cursor_style(crate::CursorStyle::PointingHand) } diff --git a/crates/workspace2/src/pane_group.rs b/crates/workspace2/src/pane_group.rs index 7416b72331b094ceeba92c0f32971c93d6dca33a..06bd506e56e68b0a6932c18f3cb1ee190f45ab40 100644 --- a/crates/workspace2/src/pane_group.rs +++ b/crates/workspace2/src/pane_group.rs @@ -564,9 +564,9 @@ mod element { use std::{cell::RefCell, iter, rc::Rc, sync::Arc}; use gpui::{ - px, relative, Along, AnyElement, Axis, Bounds, CursorStyle, Element, IntoElement, - MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point, Size, Style, - WindowContext, + px, relative, Along, AnyElement, Axis, Bounds, CursorStyle, Element, InteractiveBounds, + IntoElement, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point, + Size, Style, WindowContext, }; use parking_lot::Mutex; use smallvec::SmallVec; @@ -717,7 +717,11 @@ mod element { }; cx.with_z_index(3, |cx| { - if handle_bounds.contains(&cx.mouse_position()) { + let interactive_handle_bounds = InteractiveBounds { + bounds: handle_bounds, + stacking_order: cx.stacking_order().clone(), + }; + if interactive_handle_bounds.visibly_contains(&cx.mouse_position(), cx) { cx.set_cursor_style(match axis { Axis::Vertical => CursorStyle::ResizeUpDown, Axis::Horizontal => CursorStyle::ResizeLeftRight,