Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/main/lifecycle/window.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { app } from 'electron';
import type { Menubar } from 'electron-menubar';

import { isMacOS } from '../../shared/platform';
import { isMacOS, isWindows } from '../../shared/platform';

import { WindowConfig } from '../config';
import type MenuBuilder from '../menu';
Expand Down Expand Up @@ -61,6 +61,25 @@ export function configureWindowEvents(mb: Menubar, menuBuilder: MenuBuilder): vo
menuBuilder.setWindowVisibility(false);
});

// Windows tray blur race workaround:
// On Windows, clicking the tray icon may not transfer focus to the window,
// triggering electron-menubar's internal blur→hide timeout before first paint.
// Temporarily set alwaysOnTop so the blur handler emits 'focus-lost' instead
// of hiding; restore the user's preference after the blur window passes.
if (isWindows()) {
mb.on('after-show', () => {
const w = mb.window;
if (!w || w.isDestroyed()) return;
const restoreOnBlur = keepWindowOnBlur;
w.setAlwaysOnTop(true);
setTimeout(() => {
if (!w.isDestroyed()) {
w.setAlwaysOnTop(restoreOnBlur);
}
}, 400);
});
}

app.on('before-quit', () => {
isQuitting = true;
});
Expand Down