From dc047437c6718f22a02f72c756272d37d5d47c56 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 20 Dec 2023 10:46:36 -0700 Subject: [PATCH] Don't consider any element hovered when actively dragging Co-Authored-By: Antonio --- crates/gpui2/src/elements/div.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rs index d5284c02a166911fbc536f152ef53586e2bbe54a..54c0884870f64079ef16d1215d20b1e099646c4a 100644 --- a/crates/gpui2/src/elements/div.rs +++ b/crates/gpui2/src/elements/div.rs @@ -1311,6 +1311,7 @@ impl Interactivity { return; } let is_hovered = interactive_bounds.visibly_contains(&event.position, cx) + && !cx.has_active_drag() && has_mouse_down.borrow().is_none(); let mut was_hovered = was_hovered.borrow_mut(); @@ -1538,24 +1539,27 @@ impl Interactivity { if let Some(bounds) = bounds { let mouse_position = cx.mouse_position(); - if let Some(group_hover) = self.group_hover_style.as_ref() { - if let Some(group_bounds) = GroupBounds::get(&group_hover.group, cx) { - if group_bounds.contains(&mouse_position) + if !cx.has_active_drag() { + if let Some(group_hover) = self.group_hover_style.as_ref() { + if let Some(group_bounds) = GroupBounds::get(&group_hover.group, cx) { + if group_bounds.contains(&mouse_position) + && cx.was_top_layer(&mouse_position, cx.stacking_order()) + { + style.refine(&group_hover.style); + } + } + } + + if let Some(hover_style) = self.hover_style.as_ref() { + if bounds + .intersect(&cx.content_mask().bounds) + .contains(&mouse_position) && cx.was_top_layer(&mouse_position, cx.stacking_order()) { - style.refine(&group_hover.style); + style.refine(hover_style); } } } - if let Some(hover_style) = self.hover_style.as_ref() { - if bounds - .intersect(&cx.content_mask().bounds) - .contains(&mouse_position) - && cx.was_top_layer(&mouse_position, cx.stacking_order()) - { - style.refine(hover_style); - } - } if let Some(drag) = cx.active_drag.take() { for (state_type, group_drag_style) in &self.group_drag_over_styles {