@@ -207,7 +207,7 @@ define(function (require, exports, module) {
207207 } ) ;
208208 }
209209
210- async function showAndResizeFileDropWindow ( event ) {
210+ async function _computeNewPositionAndSizeWebkit ( $activeElement ) {
211211 // Get the current window
212212 const currentWindow = window . __TAURI__ . window . getCurrent ( ) ;
213213
@@ -216,7 +216,31 @@ define(function (require, exports, module) {
216216 // in mac, the innerSize api in tauri gets the full size including titlebar. Since our sidebar is full size
217217 const titlebarHeightIfAny = size . height - window . innerHeight ;
218218 const currentWindowPos = await currentWindow . innerPosition ( ) ;
219+ const offset = $activeElement . offset ( ) ;
220+ const width = $activeElement . outerWidth ( ) ;
221+ const height = $activeElement . outerHeight ( ) ;
222+ const x = currentWindowPos . x + offset . left ,
223+ y = currentWindowPos . y + titlebarHeightIfAny + offset . top ;
224+ const newSize = new window . __TAURI__ . window . LogicalSize ( width , height ) ;
225+ const newPosition = new window . __TAURI__ . window . LogicalPosition ( x , y ) ;
226+ return { newSize, newPosition} ;
227+ }
228+
229+ async function _computeNewPositionAndSizeWindows ( ) {
230+ const currentWindow = window . __TAURI__ . window . getCurrent ( ) ;
231+ const newSize = await currentWindow . innerSize ( ) ;
232+ const newPosition = await currentWindow . innerPosition ( ) ;
233+ return { newSize, newPosition} ;
234+ }
219235
236+ async function _computeNewPositionAndSize ( $activeElement ) {
237+ if ( Phoenix . platform === "win" ) {
238+ return _computeNewPositionAndSizeWindows ( ) ;
239+ }
240+ return _computeNewPositionAndSizeWebkit ( $activeElement ) ;
241+ }
242+
243+ async function showAndResizeFileDropWindow ( event ) {
220244 let $activeElement ;
221245 const fileDropWindow = window . __TAURI__ . window . WebviewWindow . getByLabel ( 'fileDrop' ) ;
222246 if ( $ ( "#editor-holder" ) . has ( event . target ) . length ) {
@@ -230,14 +254,7 @@ define(function (require, exports, module) {
230254 return ;
231255 }
232256
233- const offset = $activeElement . offset ( ) ;
234- const width = $activeElement . outerWidth ( ) ;
235- const height = $activeElement . outerHeight ( ) ;
236- const x = currentWindowPos . x + offset . left ,
237- y = currentWindowPos . y + titlebarHeightIfAny + offset . top ;
238- const newSize = new window . __TAURI__ . window . LogicalSize ( width , height ) ;
239- const newPosition = new window . __TAURI__ . window . LogicalPosition ( x , y ) ;
240-
257+ const { newSize, newPosition} = await _computeNewPositionAndSize ( $activeElement ) ;
241258 const currentSize = await fileDropWindow . innerSize ( ) ;
242259 const currentPosition = await fileDropWindow . innerPosition ( ) ;
243260 const isSameSize = currentSize . width === newSize . width && currentSize . height === newSize . height ;
0 commit comments