fix electron titlebar context menu freeze
This commit is contained in:
+13
-1
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user