From 057a7ec989568ebfd5800801be2009bc3cffe1ac Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Tue, 21 Jun 2022 11:23:25 -0700 Subject: [PATCH 1/2] Don't trigger hover popover action when mouse is over context menu --- crates/editor/src/element.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 5d906a9678..4b86883c55 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -511,6 +511,8 @@ impl EditorElement { cx, ); + paint.context_menu_bounds = Some(RectF::new(list_origin, context_menu.size())); + cx.scene.pop_stacking_context(); } @@ -1342,6 +1344,7 @@ impl Element for EditorElement { bounds, gutter_bounds, text_bounds, + context_menu_bounds: None, hover_bounds: None, }; @@ -1424,6 +1427,16 @@ impl Element for EditorElement { } => self.scroll(*position, *delta, *precise, layout, paint, cx), Event::KeyDown { input, .. } => self.key_down(input.as_deref(), cx), Event::MouseMoved { position, .. } => { + // Don't trigger hover popover if mouse is hovering over context menu + if paint + .context_menu_bounds + .map_or(false, |context_menu_bounds| { + context_menu_bounds.contains_point(*position) + }) + { + return false; + } + if paint .hover_bounds .map_or(false, |hover_bounds| hover_bounds.contains_point(*position)) @@ -1528,6 +1541,7 @@ pub struct PaintState { bounds: RectF, gutter_bounds: RectF, text_bounds: RectF, + context_menu_bounds: Option, hover_bounds: Option, } From 19feb627d897956c060c521004dbc3076946549b Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Tue, 21 Jun 2022 12:38:27 -0700 Subject: [PATCH 2/2] Add comment linking to long term plan --- crates/editor/src/element.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 4b86883c55..601ad98d86 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1427,6 +1427,7 @@ impl Element for EditorElement { } => self.scroll(*position, *delta, *precise, layout, paint, cx), Event::KeyDown { input, .. } => self.key_down(input.as_deref(), cx), Event::MouseMoved { position, .. } => { + // This will be handled more correctly once https://github.com/zed-industries/zed/issues/1218 is completed // Don't trigger hover popover if mouse is hovering over context menu if paint .context_menu_bounds @@ -1443,7 +1444,7 @@ impl Element for EditorElement { { return false; } - + let point = if paint.text_bounds.contains_point(*position) { let (point, overshoot) = paint.point_for_position(&self.snapshot(cx), layout, *position);