import { LogicalSize } from '@tauri-apps/api/dpi';
import { currentMonitor, type Monitor } from '@tauri-apps/api/window';
import NativeWindow from './native';
document.addEventListener(
'wheel',
e => (e.ctrlKey || e.metaKey) && Math.abs(e.deltaY) !== 0 && e.preventDefault(),
{ passive: false }
);
document.addEventListener('contextmenu', e => e.preventDefault(), { passive: false });
document.addEventListener('keydown', e => {
const isInsideAllowShortcuts = (e.target as HTMLElement)?.closest('[data-allow-shortcuts]');
if (e.ctrlKey || e.metaKey) {
if (isInsideAllowShortcuts && ['a', 'x'].includes(e.key.toLowerCase())) {
return;
} else {
if (['c', 'v'].includes(e.key.toLowerCase())) {
return;
}
}
e.preventDefault();
}
}, {
passive: false
});
const {
size: { width, height },
scaleFactor
} = await currentMonitor() as Monitor;
await Promise.all([
NativeWindow.setSize(new LogicalSize(
Math.max(Math.round(width * 0.65 / scaleFactor), 1100),
Math.max(Math.round(height * 0.71 / scaleFactor), 720)
)),
NativeWindow.center(),
]);
await NativeWindow.maximize();
await NativeWindow.show();