Skip to content

Commit 02c9332

Browse files
committed
docs: code docs for drag and drop functions for future me
1 parent 40e6f87 commit 02c9332

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/utils/DragAndDrop.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,25 @@ define(function (require, exports, module) {
207207
});
208208
}
209209

210+
const MAC_TITLE_BAR_HEIGHT = 28;
210211
async function _computeNewPositionAndSizeWebkit() {
211212
const currentWindow = window.__TAURI__.window.getCurrent();
212213
const newSize = await currentWindow.innerSize();
213214
const newPosition = await currentWindow.innerPosition();
214215
if(Phoenix.platform === "mac") {
215-
newPosition.y = newPosition.y + 28;
216-
newSize.height = newSize.height - 28;
216+
// in mac we somehow get the top left of the window including the title bar even though we are calling the
217+
// tauri innerPosition api. So we just adjust for a generally constant title bar height of mac that is 28px.
218+
newPosition.y = newPosition.y + MAC_TITLE_BAR_HEIGHT;
219+
newSize.height = newSize.height - MAC_TITLE_BAR_HEIGHT;
217220
}
218221
return {newSize, newPosition};
219222
}
220223

221224
async function _computeNewPositionAndSizeWindows() {
225+
// Note that the drop window may be on different screens if multi window setup. in windows os, there can be
226+
// of different scale factors like 1x and 1.5x on another monitor. Additionally, we may apply our own zoom
227+
// settings. So its is always better to just use the tauri provided positions. the tauri api returned values
228+
// will position the window to the correct monitor as well.
222229
const currentWindow = window.__TAURI__.window.getCurrent();
223230
const newSize = await currentWindow.innerSize();
224231
const newPosition = await currentWindow.innerPosition();

0 commit comments

Comments
 (0)