diff options
Diffstat (limited to 'src/main/index.ts')
| -rw-r--r-- | src/main/index.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main/index.ts b/src/main/index.ts index a7bed00..f913ac0 100644 --- a/src/main/index.ts +++ b/src/main/index.ts | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | import { app, BrowserWindow, Menu } from "electron"; | 1 | import { app, BrowserWindow, Menu, ipcMain } from "electron"; |
| 2 | import path from "node:path"; | 2 | import path from "node:path"; |
| 3 | import { getDb, closeDb } from "./db"; | 3 | import { getDb, closeDb } from "./db"; |
| 4 | import { registerIpcHandlers } from "./ipc/handlers"; | 4 | import { registerIpcHandlers } from "./ipc/handlers"; |
| @@ -23,6 +23,18 @@ function createWindow() { | |||
| 23 | 23 | ||
| 24 | registerIpcHandlers(mainWindow); | 24 | registerIpcHandlers(mainWindow); |
| 25 | 25 | ||
| 26 | // Maximize toggle — works identically on Linux and macOS | ||
| 27 | ipcMain.handle("window:toggleMaximize", () => { | ||
| 28 | if (mainWindow!.isMaximized()) mainWindow!.unmaximize(); | ||
| 29 | else mainWindow!.maximize(); | ||
| 30 | }); | ||
| 31 | |||
| 32 | // Push state to renderer so the button glyph stays accurate. | ||
| 33 | // On macOS, clicking the green traffic light also fires these events, | ||
| 34 | // keeping our custom button in sync with the native control. | ||
| 35 | mainWindow.on("maximize", () => mainWindow!.webContents.send("window:maximized", true)); | ||
| 36 | mainWindow.on("unmaximize", () => mainWindow!.webContents.send("window:maximized", false)); | ||
| 37 | |||
| 26 | if (isDev) { | 38 | if (isDev) { |
| 27 | const url = process.env.VITE_DEV_SERVER_URL ?? "http://localhost:5173"; | 39 | const url = process.env.VITE_DEV_SERVER_URL ?? "http://localhost:5173"; |
| 28 | mainWindow.loadURL(url).finally(() => { | 40 | mainWindow.loadURL(url).finally(() => { |
