mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-06 19:58:43 +02:00
fix: tray icon click opens main window reliably after quick prompt use
showAndFocusWindow() used BrowserWindow.getAllWindows()[0] to find the main window, which breaks once the quick prompt window is created — the array order is not guaranteed and windows[0] may resolve to the quick prompt instead, causing the show/focus calls to target a hidden, frameless window. Accept the main window reference as an explicit parameter and guard against destroyed windows with isDestroyed(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+4
-4
@@ -63,9 +63,9 @@ async function bootstrap(): Promise<void> {
|
||||
applyTitleBarTheme(mainWindow, workspace.settings.theme);
|
||||
|
||||
systemTray = new SystemTray({
|
||||
onShowWindow: showAndFocusWindow,
|
||||
onShowWindow: () => showAndFocusWindow(mainWindow!),
|
||||
onCreateScratchpad: () => {
|
||||
showAndFocusWindow();
|
||||
showAndFocusWindow(mainWindow!);
|
||||
mainWindow?.webContents.send('tray:create-scratchpad');
|
||||
},
|
||||
onQuit: () => app.quit(),
|
||||
@@ -127,8 +127,8 @@ app.on('window-all-closed', () => {
|
||||
app.on('activate', async () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
await bootstrap();
|
||||
} else {
|
||||
showAndFocusWindow();
|
||||
} else if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
showAndFocusWindow(mainWindow);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user