diff --git a/examples/dnd.rs b/examples/dnd.rs index 8a79231d6c..0a610d2bb5 100644 --- a/examples/dnd.rs +++ b/examples/dnd.rs @@ -42,7 +42,7 @@ impl ApplicationHandler for Application { event: WindowEvent, ) { match event { - WindowEvent::DragLeft + WindowEvent::DragLeft { .. } | WindowEvent::DragEntered { .. } | WindowEvent::DragMoved { .. } | WindowEvent::DragDrop { .. } => { diff --git a/examples/window.rs b/examples/window.rs index cab9426875..e8f3077330 100644 --- a/examples/window.rs +++ b/examples/window.rs @@ -541,7 +541,7 @@ impl ApplicationHandler for Application { info!("Smart zoom"); }, WindowEvent::TouchpadPressure { .. } - | WindowEvent::DragLeft + | WindowEvent::DragLeft { .. } | WindowEvent::KeyboardInput { .. } | WindowEvent::PointerEntered { .. } | WindowEvent::DragEntered { .. } diff --git a/src/event.rs b/src/event.rs index f913407d60..30d3eb5b4d 100644 --- a/src/event.rs +++ b/src/event.rs @@ -202,7 +202,16 @@ pub enum WindowEvent { }, /// The drag operation has been cancelled or left the window. On some platforms, this may occur /// even if no other drag events have occurred. - DragLeft, + DragLeft { + /// (x,y) coordinates in pixels relative to the top-left corner of the window. May be + /// negative on some platforms if something is dragged over a window's decorations (title + /// bar, frame, etc). + /// + /// ## Platform-specific + /// + /// - **Windows:** Always emits [`None`]. + position: Option>, + }, /// The window gained or lost focus. /// @@ -1236,7 +1245,7 @@ mod tests { paths: vec!["x.txt".into()], position: (0, 0).into(), }); - with_window_event(DragLeft); + with_window_event(DragLeft { position: Some((0, 0).into()) }); with_window_event(Ime(Enabled)); with_window_event(PointerMoved { device_id: None, diff --git a/src/platform_impl/apple/appkit/window_delegate.rs b/src/platform_impl/apple/appkit/window_delegate.rs index 7339911c30..40cc13ac8a 100644 --- a/src/platform_impl/apple/appkit/window_delegate.rs +++ b/src/platform_impl/apple/appkit/window_delegate.rs @@ -459,7 +459,7 @@ declare_class!( #[method(draggingExited:)] fn dragging_exited(&self, _sender: Option<&NSObject>) { trace_scope!("draggingExited:"); - self.queue_event(WindowEvent::DragLeft); + self.queue_event(WindowEvent::DragLeft { position: None } ); } } diff --git a/src/platform_impl/linux/x11/event_processor.rs b/src/platform_impl/linux/x11/event_processor.rs index 5de5b8e923..87986bb57f 100644 --- a/src/platform_impl/linux/x11/event_processor.rs +++ b/src/platform_impl/linux/x11/event_processor.rs @@ -561,7 +561,10 @@ impl EventProcessor { if xev.message_type == atoms[XdndLeave] as c_ulong { if self.dnd.has_entered { - let event = Event::WindowEvent { window_id, event: WindowEvent::DragLeft }; + let event = Event::WindowEvent { + window_id, + event: WindowEvent::DragLeft { position: Some(self.dnd.position) }, + }; callback(&self.target, event); } self.dnd.reset(); diff --git a/src/platform_impl/windows/drop_handler.rs b/src/platform_impl/windows/drop_handler.rs index 1c772099f8..1ffc802507 100644 --- a/src/platform_impl/windows/drop_handler.rs +++ b/src/platform_impl/windows/drop_handler.rs @@ -138,7 +138,7 @@ impl FileDropHandler { if drop_handler.enter_is_valid { drop_handler.send_event(Event::WindowEvent { window_id: WindowId::from_raw(drop_handler.window as usize), - event: DragLeft, + event: DragLeft { position: None }, }); }