fix electron titlebar context menu freeze

This commit is contained in:
2026-07-03 10:38:21 +09:00
parent 5c4426206e
commit 195d3953e4
2 changed files with 60 additions and 5 deletions
+13 -1
View File
@@ -617,6 +617,16 @@ function attachDevToolsShortcut(window: BrowserWindow): void {
})
}
function suppressSystemContextMenu(window: BrowserWindow): void {
type SystemContextMenuWindow = BrowserWindow & {
on(event: 'system-context-menu', listener: (event: { preventDefault: () => void }) => void): BrowserWindow
}
;(window as SystemContextMenuWindow).on('system-context-menu', (event) => {
event.preventDefault()
})
}
function createWindow(): void {
const appWindows = new Map<string, BrowserWindow>()
const appProcesses = new Map<string, ChildProcess>()
@@ -634,6 +644,7 @@ function createWindow(): void {
}
})
attachDevToolsShortcut(mainWindow)
suppressSystemContextMenu(mainWindow)
mainWindow.on('ready-to-show', () => {
setTimeout(() => {
@@ -822,7 +833,7 @@ function createWindow(): void {
}
const existingProc = appProcesses.get(appName)
if (existingProc) {
if (is.dev && handoffCode && audienceApp !== 'ADS IDE') {
if (handoffCode) {
existingProc.kill()
appProcesses.delete(appName)
} else {
@@ -928,6 +939,7 @@ function createWindow(): void {
})
appWindows.set(appName, appWin)
attachDevToolsShortcut(appWin)
suppressSystemContextMenu(appWin)
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
appWin.loadURL(process.env['ELECTRON_RENDERER_URL'])