@@ -112,7 +112,7 @@ define(function (require, exports, module) {
112112 }
113113
114114 CommandManager . execute ( Commands . CMD_ADD_TO_WORKINGSET_AND_OPEN ,
115- { fullPath : path , silent : true } )
115+ { fullPath : path , silent : true } )
116116 . done ( function ( ) {
117117 result . resolve ( ) ;
118118 } )
@@ -153,7 +153,7 @@ define(function (require, exports, module) {
153153 message += "<ul class='dialog-list'>" ;
154154 errorFiles . forEach ( function ( info ) {
155155 message += "<li><span class='dialog-filename'>" +
156- StringUtils . breakableUrl ( ProjectManager . makeProjectRelativeIfPossible ( info . path ) ) +
156+ StringUtils . breakableUrl ( ProjectManager . getProjectRelativeOrDisplayPath ( info . path ) ) +
157157 "</span> - " + errorToString ( info . error ) +
158158 "</li>" ;
159159 } ) ;
@@ -168,6 +168,77 @@ define(function (require, exports, module) {
168168 } ) ;
169169 }
170170
171+ if ( Phoenix . isNativeApp ) {
172+ window . __TAURI__ . event . listen ( 'file-drop-event-phoenix' , ( { payload} ) => {
173+ if ( ! payload || ! payload . pathList || ! payload . pathList . length || ! payload . windowLabelOfListener
174+ || payload . windowLabelOfListener !== window . __TAURI__ . window . appWindow . label ) {
175+ return ;
176+ }
177+ const droppedVirtualPaths = [ ] ;
178+ for ( const droppedPath of payload . pathList ) {
179+ try {
180+ droppedVirtualPaths . push ( window . fs . getTauriVirtualPath ( droppedPath ) ) ;
181+ } catch ( e ) {
182+ console . error ( "Error resolving dropped path: " , droppedPath ) ;
183+ }
184+ }
185+ openDroppedFiles ( droppedVirtualPaths ) ;
186+ } ) ;
187+ }
188+
189+ async function showAndResizeFileDropWindow ( event ) {
190+ // Get the current window
191+ const currentWindow = window . __TAURI__ . window . getCurrent ( ) ;
192+
193+ // Get the bounds of the current window
194+ const size = await currentWindow . innerSize ( ) ;
195+ // in mac, the innerSize api in tauri gets the full size including titlebar. Since our sidebar is full size
196+ const titlebarHeightIfAny = size . height - window . innerHeight ;
197+ const currentWindowPos = await currentWindow . innerPosition ( ) ;
198+
199+ let $activeElement ;
200+ const fileDropWindow = window . __TAURI__ . window . WebviewWindow . getByLabel ( 'fileDrop' ) ;
201+ if ( $ ( "#editor-holder" ) . has ( event . target ) . length ) {
202+ $activeElement = $ ( "#editor-holder" ) ;
203+ } else if ( $ ( "#sidebar" ) . has ( event . target ) . length ) {
204+ $activeElement = $ ( "#sidebar" ) ;
205+ } else {
206+ await fileDropWindow . hide ( ) ;
207+ }
208+ if ( ! $activeElement ) {
209+ return ;
210+ }
211+
212+ const offset = $activeElement . offset ( ) ;
213+ const width = $activeElement . outerWidth ( ) ;
214+ const height = $activeElement . outerHeight ( ) ;
215+ const x = currentWindowPos . x + offset . left ,
216+ y = currentWindowPos . y + titlebarHeightIfAny + offset . top ;
217+ const newSize = new window . __TAURI__ . window . LogicalSize ( width , height ) ;
218+ const newPosition = new window . __TAURI__ . window . LogicalPosition ( x , y ) ;
219+
220+ const currentSize = await fileDropWindow . innerSize ( ) ;
221+ const currentPosition = await fileDropWindow . innerPosition ( ) ;
222+ const isSameSize = currentSize . width === newSize . width && currentSize . height === newSize . height ;
223+ const isSamePosition = currentPosition . x === newPosition . x && currentPosition . y === newPosition . y ;
224+ window . __TAURI__ . event . emit ( "drop-attach-on-window" , {
225+ projectName : window . path . basename ( ProjectManager . getProjectRoot ( ) . fullPath ) ,
226+ dropMessage : "Drop files to open or drop a folder to open it as a project" ,
227+ windowLabelOfListener : window . __TAURI__ . window . appWindow . label
228+ } ) ;
229+ if ( isSameSize && isSamePosition && ( await fileDropWindow . isVisible ( ) ) ) {
230+ return ; // Do nothing if the window is already at the correct size and position and visible
231+ }
232+
233+ // Resize the fileDrop window to match the current window
234+ await fileDropWindow . setSize ( newSize ) ;
235+ await fileDropWindow . setPosition ( newPosition ) ;
236+
237+ // Show the fileDrop window
238+ await fileDropWindow . show ( ) ;
239+ await fileDropWindow . setAlwaysOnTop ( true ) ;
240+ await fileDropWindow . setAlwaysOnTop ( false ) ;
241+ }
171242
172243 /**
173244 * Attaches global drag & drop handlers to this window. This enables dropping files/folders to open them, and also
@@ -181,6 +252,12 @@ define(function (require, exports, module) {
181252 var files = event . dataTransfer . files ;
182253
183254 stopURIListPropagation ( files , event ) ;
255+ if ( Phoenix . isNativeApp && Phoenix . platform !== "linux" &&
256+ event . dataTransfer . types && event . dataTransfer . types . includes ( "Files" ) ) {
257+ // in linux, there is a bug in ubuntu 24 where dropping a file will cause a ghost icon which only
258+ // goes away on reboot. So we dont support drop files in linux for now.
259+ showAndResizeFileDropWindow ( event ) ;
260+ }
184261
185262 if ( files && files . length ) {
186263 event . stopPropagation ( ) ;
0 commit comments