Skip to content

Commit c0d7975

Browse files
arunabose
authored andcommitted
fix: drag and drop window in mac
1 parent e7d1251 commit c0d7975

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

src/drop-files.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
});
1818
});
1919
window.__TAURI__.event.listen('tauri://file-drop-cancelled', (event) => {
20-
__TAURI__.window.appWindow.hide();
20+
//__TAURI__.window.appWindow.hide();
2121
});
2222
window.__TAURI__.event.listen('tauri://file-drop-hover', (event) => {
2323
if(!event || !event.payload || !dropProjectMessage || !dropMessage){
@@ -49,17 +49,17 @@
4949
__TAURI__.window.appWindow.hide();
5050
});
5151
window.addEventListener('dragleave', ()=>{
52-
__TAURI__.window.appWindow.hide();
52+
//__TAURI__.window.appWindow.hide();
5353
});
5454
window.addEventListener('dragend', ()=>{
55-
__TAURI__.window.appWindow.hide();
55+
//__TAURI__.window.appWindow.hide();
5656
});
5757
window.addEventListener('click', ()=>{
5858
__TAURI__.window.appWindow.hide();
5959
});
6060
document.addEventListener('visibilitychange', () => {
6161
if (document.hidden) {
62-
__TAURI__.window.appWindow.hide();
62+
//__TAURI__.window.appWindow.hide();
6363
}
6464
});
6565
setInterval(async ()=>{

src/utils/DragAndDrop.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,12 @@ define(function (require, exports, module) {
207207
});
208208
}
209209

210-
async function _computeNewPositionAndSizeWebkit($activeElement) {
211-
// Get the current window
210+
async function _computeNewPositionAndSizeWebkit() {
212211
const currentWindow = window.__TAURI__.window.getCurrent();
213-
214-
// Get the bounds of the current window
215-
const size = await currentWindow.innerSize();
216-
// in mac, the innerSize api in tauri gets the full size including titlebar. Since our sidebar is full size
217-
const titlebarHeightIfAny = size.height - window.innerHeight;
218-
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);
212+
const newSize = await currentWindow.innerSize();
213+
const newPosition = await currentWindow.innerPosition();
214+
newPosition.y = newPosition.y + 28;
215+
newSize.height = newSize.height - 28;
226216
return {newSize, newPosition};
227217
}
228218

@@ -233,11 +223,11 @@ define(function (require, exports, module) {
233223
return {newSize, newPosition};
234224
}
235225

236-
async function _computeNewPositionAndSize($activeElement) {
226+
async function _computeNewPositionAndSize() {
237227
if(Phoenix.platform === "win") {
238228
return _computeNewPositionAndSizeWindows();
239229
}
240-
return _computeNewPositionAndSizeWebkit($activeElement);
230+
return _computeNewPositionAndSizeWebkit();
241231
}
242232

243233
async function showAndResizeFileDropWindow(event) {

0 commit comments

Comments
 (0)