;(function () {
const osName = __TEMPLATE_os_name__
const TAURI_DRAG_REGION_ATTR = 'data-tauri-drag-region'
let initialX = 0
let initialY = 0
document.addEventListener('mousedown', (e) => {
const attr = e.target.getAttribute(TAURI_DRAG_REGION_ATTR)
if (
attr !== null
&& attr !== 'false'
&& e.button === 0
&& (e.detail === 1 || e.detail === 2)
) {
if (osName === 'macos' && e.detail === 2) {
initialX = e.clientX
initialY = e.clientY
return
}
e.preventDefault()
e.stopImmediatePropagation()
const cmd = e.detail === 2 ? 'internal_toggle_maximize' : 'start_dragging'
window.__TAURI_INTERNALS__.invoke('plugin:window|' + cmd)
}
})
if (osName === 'macos') {
document.addEventListener('mouseup', (e) => {
const attr = e.target.getAttribute(TAURI_DRAG_REGION_ATTR)
if (
attr !== null
&& attr !== 'false'
&& e.button === 0
&& e.detail === 2
&& e.clientX === initialX
&& e.clientY === initialY
) {
window.__TAURI_INTERNALS__.invoke(
'plugin:window|internal_toggle_maximize'
)
}
})
}
})()