diff --git a/src/main/index.ts b/src/main/index.ts index 6a6c423..8cea37e 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, ipcMain } from 'electron'; +import { app, BrowserWindow, ipcMain, screen } from 'electron'; import * as path from 'path'; import * as os from 'os'; import { loadSeedConfig } from './config_loader'; @@ -18,9 +18,13 @@ async function createWindow() { cachedFullConfig = await fetchFullConfig(cachedSeed); } + const { bounds } = screen.getPrimaryDisplay(); + mainWindow = new BrowserWindow({ - width: 1600, - height: 900, + width: bounds.width, + height: bounds.height, + x: bounds.x, + y: bounds.y, title: 'OSIT Aether Launcher (Native)', webPreferences: { preload: path.join(__dirname, '../preload/index.js'), @@ -55,15 +59,28 @@ registerShellHandlers(); registerFileHandlers(); registerSystemHandlers(); -app.on('ready', createWindow); +// Single instance lock — if another instance is already running, focus it and quit. +const gotTheLock = app.requestSingleInstanceLock(); +if (!gotTheLock) { + app.quit(); +} else { + app.on('second-instance', () => { + if (mainWindow) { + if (mainWindow.isMinimized()) mainWindow.restore(); + mainWindow.focus(); + } + }); -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') app.quit(); -}); + app.on('ready', createWindow); -app.on('activate', () => { - if (mainWindow === null) createWindow(); -}); + app.on('window-all-closed', () => { + if (process.platform !== 'darwin') app.quit(); + }); + + app.on('activate', () => { + if (mainWindow === null) createWindow(); + }); +} ipcMain.handle('get-seed-config', async () => cachedSeed || await loadSeedConfig()); ipcMain.handle('get-device-config', async () => cachedFullConfig);