Files
MyGoNavi/frontend/src/utils/macWindow.ts

43 lines
1.2 KiB
TypeScript

export const getMacNativeTitlebarPaddingLeft = (uiScale: number, enabled: boolean): number => {
if (!enabled) {
return Math.max(12, Math.round(16 * uiScale));
}
return Math.max(88, Math.round(96 * uiScale));
};
export const getMacNativeTitlebarPaddingRight = (uiScale: number, enabled: boolean): number => {
if (!enabled) {
return 0;
}
return Math.max(12, Math.round(16 * uiScale));
};
export const shouldHandleMacNativeFullscreenShortcut = (
isMacRuntime: boolean,
useNativeMacWindowControls: boolean,
event: Pick<KeyboardEvent, 'ctrlKey' | 'metaKey' | 'altKey' | 'key'>,
): boolean => {
if (!isMacRuntime || !useNativeMacWindowControls) {
return false;
}
if (!event.ctrlKey || !event.metaKey || event.altKey) {
return false;
}
return String(event.key || '').toLowerCase() === 'f';
};
export const shouldSuppressMacNativeEscapeExit = (
isMacRuntime: boolean,
useNativeMacWindowControls: boolean,
isFullscreen: boolean,
event: Pick<KeyboardEvent, 'key' | 'defaultPrevented'>,
): boolean => {
if (!isMacRuntime || !useNativeMacWindowControls || !isFullscreen) {
return false;
}
if (event.defaultPrevented) {
return false;
}
return String(event.key || '') === 'Escape';
};