@@ -29,10 +29,10 @@ const WINDOW_FOCUS_EVENT: &str = "tauri://focus";
2929const WINDOW_BLUR_EVENT : & str = "tauri://blur" ;
3030const WINDOW_SCALE_FACTOR_CHANGED_EVENT : & str = "tauri://scale-change" ;
3131const WINDOW_THEME_CHANGED : & str = "tauri://theme-changed" ;
32- pub const DRAG_EVENT : & str = "tauri://drag" ;
33- pub const DROP_EVENT : & str = "tauri://drop " ;
34- pub const DROP_HOVER_EVENT : & str = "tauri://drop-over " ;
35- pub const DROP_CANCELLED_EVENT : & str = "tauri://drag-cancelled " ;
32+ pub ( crate ) const DRAG_ENTER_EVENT : & str = "tauri://drag-enter " ;
33+ pub ( crate ) const DRAG_OVER_EVENT : & str = "tauri://drag-over " ;
34+ pub ( crate ) const DRAG_DROP_EVENT : & str = "tauri://drag-drop " ;
35+ pub ( crate ) const DRAG_LEAVE_EVENT : & str = "tauri://drag-leave " ;
3636
3737pub struct WindowManager < R : Runtime > {
3838 pub windows : Mutex < HashMap < String , Window < R > > > ,
@@ -144,13 +144,9 @@ impl<R: Runtime> Window<R> {
144144}
145145
146146#[ derive( Serialize , Clone ) ]
147- pub struct DragDropPayload < ' a > {
148- pub paths : & ' a Vec < PathBuf > ,
149- pub position : & ' a PhysicalPosition < f64 > ,
150- }
151-
152- #[ derive( Serialize , Clone ) ]
153- pub struct DragOverPayload < ' a > {
147+ pub ( crate ) struct DragDropPayload < ' a > {
148+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
149+ pub paths : Option < & ' a Vec < PathBuf > > ,
154150 pub position : & ' a PhysicalPosition < f64 > ,
155151}
156152
@@ -194,28 +190,38 @@ fn on_window_event<R: Runtime>(window: &Window<R>, event: &WindowEvent) -> crate
194190 } ,
195191 ) ?,
196192 WindowEvent :: DragDrop ( event) => match event {
197- DragDropEvent :: Dragged { paths, position } => {
198- let payload = DragDropPayload { paths, position } ;
193+ DragDropEvent :: Enter { paths, position } => {
194+ let payload = DragDropPayload {
195+ paths : Some ( paths) ,
196+ position,
197+ } ;
199198
200199 if window. is_webview_window ( ) {
201- window. emit_to ( EventTarget :: labeled ( window. label ( ) ) , DRAG_EVENT , payload) ?
200+ window. emit_to (
201+ EventTarget :: labeled ( window. label ( ) ) ,
202+ DRAG_ENTER_EVENT ,
203+ payload,
204+ ) ?
202205 } else {
203- window. emit_to_window ( DRAG_EVENT , payload) ?
206+ window. emit_to_window ( DRAG_ENTER_EVENT , payload) ?
204207 }
205208 }
206- DragDropEvent :: DragOver { position } => {
207- let payload = DragOverPayload { position } ;
209+ DragDropEvent :: Over { position } => {
210+ let payload = DragDropPayload {
211+ position,
212+ paths : None ,
213+ } ;
208214 if window. is_webview_window ( ) {
209215 window. emit_to (
210216 EventTarget :: labeled ( window. label ( ) ) ,
211- DROP_HOVER_EVENT ,
217+ DRAG_OVER_EVENT ,
212218 payload,
213219 ) ?
214220 } else {
215- window. emit_to_window ( DROP_HOVER_EVENT , payload) ?
221+ window. emit_to_window ( DRAG_OVER_EVENT , payload) ?
216222 }
217223 }
218- DragDropEvent :: Dropped { paths, position } => {
224+ DragDropEvent :: Drop { paths, position } => {
219225 let scopes = window. state :: < Scopes > ( ) ;
220226 for path in paths {
221227 if path. is_file ( ) {
@@ -224,23 +230,26 @@ fn on_window_event<R: Runtime>(window: &Window<R>, event: &WindowEvent) -> crate
224230 let _ = scopes. allow_directory ( path, true ) ;
225231 }
226232 }
227- let payload = DragDropPayload { paths, position } ;
233+ let payload = DragDropPayload {
234+ paths : Some ( paths) ,
235+ position,
236+ } ;
228237
229238 if window. is_webview_window ( ) {
230- window. emit_to ( EventTarget :: labeled ( window. label ( ) ) , DROP_EVENT , payload) ?
239+ window. emit_to (
240+ EventTarget :: labeled ( window. label ( ) ) ,
241+ DRAG_DROP_EVENT ,
242+ payload,
243+ ) ?
231244 } else {
232- window. emit_to_window ( DROP_EVENT , payload) ?
245+ window. emit_to_window ( DRAG_DROP_EVENT , payload) ?
233246 }
234247 }
235- DragDropEvent :: Cancelled => {
248+ DragDropEvent :: Leave => {
236249 if window. is_webview_window ( ) {
237- window. emit_to (
238- EventTarget :: labeled ( window. label ( ) ) ,
239- DROP_CANCELLED_EVENT ,
240- ( ) ,
241- ) ?
250+ window. emit_to ( EventTarget :: labeled ( window. label ( ) ) , DRAG_LEAVE_EVENT , ( ) ) ?
242251 } else {
243- window. emit_to_window ( DROP_CANCELLED_EVENT , ( ) ) ?
252+ window. emit_to_window ( DRAG_LEAVE_EVENT , ( ) ) ?
244253 }
245254 }
246255 _ => unimplemented ! ( ) ,
0 commit comments