fix electron titlebar context menu freeze

This commit is contained in:
chyoo
2026-07-03 10:38:39 +09:00
parent a50c7c6945
commit 429fceda43
2 changed files with 73 additions and 4 deletions
+11
View File
@@ -3119,6 +3119,16 @@ function attachDevToolsShortcut(win: BrowserWindow): void {
})
}
function suppressSystemContextMenu(win: BrowserWindow): void {
type SystemContextMenuWindow = BrowserWindow & {
on(event: 'system-context-menu', listener: (event: { preventDefault: () => void }) => void): BrowserWindow
}
;(win as SystemContextMenuWindow).on('system-context-menu', (event) => {
event.preventDefault()
})
}
function toggleFocusedDevTools(): void {
const target = BrowserWindow.getFocusedWindow()
if (!target) return
@@ -3178,6 +3188,7 @@ function createWindow(): void {
})
attachDevToolsShortcut(mainWindow)
suppressSystemContextMenu(mainWindow)
mainWindow.once('ready-to-show', () => {
setTimeout(() => {
splashWindow?.close()