multi-window fixes

This commit is contained in:
Eugene Pankov
2018-10-26 16:17:20 +02:00
parent 394587301c
commit 2b4d3e99b6
4 changed files with 57 additions and 15 deletions

View File

@@ -117,6 +117,9 @@ export class Window {
}
send (event, ...args) {
if (!this.window) {
return
}
this.window.webContents.send(event, ...args)
}
@@ -154,19 +157,31 @@ export class Window {
}
})
ipcMain.on('window-focus', () => {
ipcMain.on('window-focus', event => {
if (event.sender !== this.window.webContents) {
return
}
this.window.focus()
})
ipcMain.on('window-maximize', () => {
ipcMain.on('window-maximize', event => {
if (event.sender !== this.window.webContents) {
return
}
this.window.maximize()
})
ipcMain.on('window-unmaximize', () => {
ipcMain.on('window-unmaximize', event => {
if (event.sender !== this.window.webContents) {
return
}
this.window.unmaximize()
})
ipcMain.on('window-toggle-maximize', () => {
ipcMain.on('window-toggle-maximize', event => {
if (event.sender !== this.window.webContents) {
return
}
if (this.window.isMaximized()) {
this.window.unmaximize()
} else {
@@ -174,23 +189,38 @@ export class Window {
}
})
ipcMain.on('window-minimize', () => {
ipcMain.on('window-minimize', event => {
if (event.sender !== this.window.webContents) {
return
}
this.window.minimize()
})
ipcMain.on('window-set-bounds', (_event, bounds) => {
ipcMain.on('window-set-bounds', (event, bounds) => {
if (event.sender !== this.window.webContents) {
return
}
this.window.setBounds(bounds)
})
ipcMain.on('window-set-always-on-top', (_event, flag) => {
ipcMain.on('window-set-always-on-top', (event, flag) => {
if (event.sender !== this.window.webContents) {
return
}
this.window.setAlwaysOnTop(flag)
})
ipcMain.on('window-set-vibrancy', (_event, enabled, type) => {
ipcMain.on('window-set-vibrancy', (event, enabled, type) => {
if (event.sender !== this.window.webContents) {
return
}
this.setVibrancy(enabled, type)
})
ipcMain.on('window-set-title', (_event, title) => {
ipcMain.on('window-set-title', (event, title) => {
if (event.sender !== this.window.webContents) {
return
}
this.window.setTitle(title)
})