From a9f553729e45a41d8a43ec28593b7797d3b8bffd Mon Sep 17 00:00:00 2001 From: lucas lelievre Date: Thu, 26 Mar 2026 08:09:10 +0100 Subject: [PATCH] Electron fixes macos (#1797) --- gui/electron/main/index.ts | 7 ++++--- gui/electron/preload/index.ts | 1 + gui/electron/preload/interface.d.ts | 1 + gui/electron/shared.ts | 2 +- gui/src/components/TopBar.tsx | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 34a766432..2af187d18 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -273,6 +273,9 @@ function createWindow() { case 'close': mainWindow?.close(); break; + case 'hide': + mainWindow?.hide(); + break; case 'minimize': mainWindow?.minimize(); break; @@ -454,9 +457,7 @@ app.whenReady().then(async () => { logger.info('SlimeVR started!'); app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { - app.quit(); - } + app.quit(); }); app.on('before-quit', async (event) => { diff --git a/gui/electron/preload/index.ts b/gui/electron/preload/index.ts index e9682ca0d..376393c94 100644 --- a/gui/electron/preload/index.ts +++ b/gui/electron/preload/index.ts @@ -12,6 +12,7 @@ contextBridge.exposeInMainWorld('electronAPI', { openUrl: (url) => ipcRenderer.invoke(IPC_CHANNELS.OPEN_URL, url), osStats: () => ipcRenderer.invoke(IPC_CHANNELS.OS_STATS), close: () => ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'close'), + hide: () => ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'hide'), minimize: () => ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'minimize'), maximize: () => ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'maximize'), getStorage: async (type) => { diff --git a/gui/electron/preload/interface.d.ts b/gui/electron/preload/interface.d.ts index 03c47a1f7..e7822f9a5 100644 --- a/gui/electron/preload/interface.d.ts +++ b/gui/electron/preload/interface.d.ts @@ -43,6 +43,7 @@ export interface IElectronAPI { openLogsFolder: () => Promise; openConfigFolder: () => Promise; close: () => void; + hide: () => void; minimize: () => void; maximize: () => void; showDecorations: (decorations: boolean) => void; diff --git a/gui/electron/shared.ts b/gui/electron/shared.ts index 1364550bd..5abe21876 100644 --- a/gui/electron/shared.ts +++ b/gui/electron/shared.ts @@ -25,7 +25,7 @@ export const IPC_CHANNELS = { export interface IpcInvokeMap { [IPC_CHANNELS.OPEN_URL]: (url: string) => void; [IPC_CHANNELS.OS_STATS]: () => Promise; - [IPC_CHANNELS.WINDOW_ACTIONS]: (action: 'close' | 'minimize' | 'maximize') => void; + [IPC_CHANNELS.WINDOW_ACTIONS]: (action: 'close' | 'minimize' | 'maximize' | 'hide') => void; [IPC_CHANNELS.LOG]: (type: 'info' | 'error' | 'warn', ...args: unknown[]) => void; [IPC_CHANNELS.OPEN_DIALOG]: ( options: OpenDialogOptions diff --git a/gui/src/components/TopBar.tsx b/gui/src/components/TopBar.tsx index e15006485..60d7b2d6e 100644 --- a/gui/src/components/TopBar.tsx +++ b/gui/src/components/TopBar.tsx @@ -81,7 +81,7 @@ export function TopBar({ } if (config?.useTray && !dontTray) { - electron.api.minimize(); + electron.api.hide(); } else if ( config?.connectedTrackersWarning && connectedIMUTrackers.filter(