diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rs index 57fd3d6a8af274d305d37dbc4d2d62baba8ccbd3..fa1eb9e5b63454d0a3fa370913e094f30c3ad68c 100644 --- a/crates/gpui2/src/elements/div.rs +++ b/crates/gpui2/src/elements/div.rs @@ -1186,14 +1186,13 @@ impl Interactivity { cx.on_mouse_event({ let pending_mouse_down = pending_mouse_down.clone(); move |event: &MouseMoveEvent, phase, cx| { - let mut pending_mouse_down = pending_mouse_down.borrow_mut(); + if phase == DispatchPhase::Capture { + return; + } + let mut pending_mouse_down = pending_mouse_down.borrow_mut(); if let Some(mouse_down) = pending_mouse_down.clone() { - if cx.active_drag.is_some() { - if phase == DispatchPhase::Capture { - cx.notify(); - } - } else if phase == DispatchPhase::Bubble + if !cx.has_active_drag() && (event.position - mouse_down.position).magnitude() > DRAG_THRESHOLD { diff --git a/crates/gpui2/src/window.rs b/crates/gpui2/src/window.rs index 365338611b60757bced2b473a67f3323c0fbf9b9..cc435bf0b2463c311f8b0833003c054ee4341f27 100644 --- a/crates/gpui2/src/window.rs +++ b/crates/gpui2/src/window.rs @@ -1516,15 +1516,24 @@ impl<'a> WindowContext<'a> { } } - if self.app.propagate_event && event.downcast_ref::().is_some() { - self.active_drag = None; - } - self.window .rendered_frame .mouse_listeners .insert(event.type_id(), handlers); } + + if self.app.propagate_event && self.has_active_drag() { + if event.is::() { + // If this was a mouse move event, redraw the window so that the + // active drag can follow the mouse cursor. + self.notify(); + } else if event.is::() { + // If this was a mouse up event, cancel the active drag and redraw + // the window. + self.active_drag = None; + self.notify(); + } + } } fn dispatch_key_event(&mut self, event: &dyn Any) {