@@ -13,18 +13,17 @@ use windows_sys::Win32::System::Ole::{CF_HDROP, DROPEFFECT_COPY, DROPEFFECT_NONE
1313use windows_sys:: Win32 :: UI :: Shell :: { DragFinish , DragQueryFileW , HDROP } ;
1414
1515use crate :: dpi:: PhysicalPosition ;
16- use crate :: event:: { Event , WindowEvent } ;
16+ use crate :: event:: WindowEvent ;
1717use crate :: platform_impl:: platform:: definitions:: {
1818 IDataObject , IDataObjectVtbl , IDropTarget , IDropTargetVtbl , IUnknown , IUnknownVtbl ,
1919} ;
20- use crate :: window:: WindowId ;
2120
2221#[ repr( C ) ]
2322pub struct FileDropHandlerData {
2423 pub interface : IDropTarget ,
2524 refcount : AtomicUsize ,
2625 window : HWND ,
27- send_event : Box < dyn Fn ( Event ) > ,
26+ send_event : Box < dyn Fn ( WindowEvent ) > ,
2827 cursor_effect : u32 ,
2928 valid : bool , /* If the currently hovered item is not valid there must not be any
3029 * `DragLeft` emitted */
@@ -36,7 +35,7 @@ pub struct FileDropHandler {
3635
3736#[ allow( non_snake_case) ]
3837impl FileDropHandler {
39- pub ( crate ) fn new ( window : HWND , send_event : Box < dyn Fn ( Event ) > ) -> FileDropHandler {
38+ pub ( crate ) fn new ( window : HWND , send_event : Box < dyn Fn ( WindowEvent ) > ) -> FileDropHandler {
4039 let data = Box :: new ( FileDropHandlerData {
4140 interface : IDropTarget { lpVtbl : & DROP_TARGET_VTBL as * const IDropTargetVtbl } ,
4241 refcount : AtomicUsize :: new ( 1 ) ,
@@ -92,10 +91,7 @@ impl FileDropHandler {
9291 let hdrop = unsafe { Self :: iterate_filenames ( pDataObj, |path| paths. push ( path) ) } ;
9392 drop_handler. valid = hdrop. is_some ( ) ;
9493 if drop_handler. valid {
95- drop_handler. send_event ( Event :: WindowEvent {
96- window_id : WindowId :: from_raw ( drop_handler. window as usize ) ,
97- event : WindowEvent :: DragEntered { paths, position } ,
98- } ) ;
94+ ( drop_handler. send_event ) ( WindowEvent :: DragEntered { paths, position } ) ;
9995 }
10096 drop_handler. cursor_effect =
10197 if drop_handler. valid { DROPEFFECT_COPY } else { DROPEFFECT_NONE } ;
@@ -119,10 +115,7 @@ impl FileDropHandler {
119115 ScreenToClient ( drop_handler. window , & mut pt) ;
120116 }
121117 let position = PhysicalPosition :: new ( pt. x as f64 , pt. y as f64 ) ;
122- drop_handler. send_event ( Event :: WindowEvent {
123- window_id : WindowId :: from_raw ( drop_handler. window as usize ) ,
124- event : WindowEvent :: DragMoved { position } ,
125- } ) ;
118+ ( drop_handler. send_event ) ( WindowEvent :: DragMoved { position } ) ;
126119 }
127120 unsafe {
128121 * pdwEffect = drop_handler. cursor_effect ;
@@ -134,10 +127,7 @@ impl FileDropHandler {
134127 pub unsafe extern "system" fn DragLeave ( this : * mut IDropTarget ) -> HRESULT {
135128 let drop_handler = unsafe { Self :: from_interface ( this) } ;
136129 if drop_handler. valid {
137- drop_handler. send_event ( Event :: WindowEvent {
138- window_id : WindowId :: from_raw ( drop_handler. window as usize ) ,
139- event : WindowEvent :: DragLeft { position : None } ,
140- } ) ;
130+ ( drop_handler. send_event ) ( WindowEvent :: DragLeft { position : None } ) ;
141131 }
142132
143133 S_OK
@@ -159,10 +149,7 @@ impl FileDropHandler {
159149 let position = PhysicalPosition :: new ( pt. x as f64 , pt. y as f64 ) ;
160150 let mut paths = Vec :: new ( ) ;
161151 let hdrop = unsafe { Self :: iterate_filenames ( pDataObj, |path| paths. push ( path) ) } ;
162- drop_handler. send_event ( Event :: WindowEvent {
163- window_id : WindowId :: from_raw ( drop_handler. window as usize ) ,
164- event : WindowEvent :: DragDropped { paths, position } ,
165- } ) ;
152+ ( drop_handler. send_event ) ( WindowEvent :: DragDropped { paths, position } ) ;
166153 if let Some ( hdrop) = hdrop {
167154 unsafe {
168155 DragFinish ( hdrop) ;
@@ -232,12 +219,6 @@ impl FileDropHandler {
232219 }
233220}
234221
235- impl FileDropHandlerData {
236- fn send_event ( & self , event : Event ) {
237- ( self . send_event ) ( event) ;
238- }
239- }
240-
241222impl Drop for FileDropHandler {
242223 fn drop ( & mut self ) {
243224 unsafe {
0 commit comments