Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Update mouse position during file drag and drop

Kirill Bulatov0a04c5734baa
diff --git a/crates/gpui2/src/window.rs b/crates/gpui2/src/window.rs
index 8b3aa7a1176..fc9b8b8de88 100644
--- a/crates/gpui2/src/window.rs
+++ b/crates/gpui2/src/window.rs
@@ -1,7 +1,7 @@
use crate::{
px, size, Action, AnyBox, AnyDrag, AnyView, AppContext, AsyncWindowContext, AvailableSpace,
- Bounds, BoxShadow, Context, Corners, DevicePixels, DispatchContext, DisplayId, ExternalPaths,
- Edges, Effect, Element, EntityId, EventEmitter, FileDropEvent, FocusEvent, FontId,
+ Bounds, BoxShadow, Context, Corners, DevicePixels, DispatchContext, DisplayId, Edges, Effect,
+ Element, EntityId, EventEmitter, ExternalPaths, FileDropEvent, FocusEvent, FontId,
GlobalElementId, GlyphId, Handle, Hsla, ImageData, InputEvent, IsZero, KeyListener, KeyMatch,
KeyMatcher, Keystroke, LayoutId, MainThread, MainThreadOnly, Modifiers, MonochromeSprite,
MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Path, Pixels, PlatformAtlas,
@@ -899,6 +899,7 @@ impl<'a, 'w> WindowContext<'a, 'w> {
}
InputEvent::FileDrop(file_drop) => match file_drop {
FileDropEvent::Entered { position, files } => {
+ self.window.mouse_position = position;
self.active_drag.get_or_insert_with(|| AnyDrag {
drag_handle_view: None,
cursor_offset: position,
@@ -912,17 +913,23 @@ impl<'a, 'w> WindowContext<'a, 'w> {
modifiers: Modifiers::default(),
})
}
- FileDropEvent::Pending { position } => InputEvent::MouseMove(MouseMoveEvent {
- position,
- pressed_button: Some(MouseButton::Left),
- modifiers: Modifiers::default(),
- }),
- FileDropEvent::Submit { position } => InputEvent::MouseUp(MouseUpEvent {
- button: MouseButton::Left,
- position,
- modifiers: Modifiers::default(),
- click_count: 1,
- }),
+ FileDropEvent::Pending { position } => {
+ self.window.mouse_position = position;
+ InputEvent::MouseMove(MouseMoveEvent {
+ position,
+ pressed_button: Some(MouseButton::Left),
+ modifiers: Modifiers::default(),
+ })
+ }
+ FileDropEvent::Submit { position } => {
+ self.window.mouse_position = position;
+ InputEvent::MouseUp(MouseUpEvent {
+ button: MouseButton::Left,
+ position,
+ modifiers: Modifiers::default(),
+ click_count: 1,
+ })
+ }
FileDropEvent::Exited => InputEvent::MouseUp(MouseUpEvent {
button: MouseButton::Left,
position: Point::default(),
diff --git a/crates/ui2/src/components/panes.rs b/crates/ui2/src/components/panes.rs
index 77b6817d89f..fd1ec56ae7c 100644
--- a/crates/ui2/src/components/panes.rs
+++ b/crates/ui2/src/components/panes.rs
@@ -56,7 +56,6 @@ impl<S: 'static + Send + Sync> Pane<S> {
.children(self.children.drain(..)),
)
.child(
- // TODO kb! Figure out why we can't we see the red background when we drag a file over this div.
div()
.z_index(1)
.id("drag-target")