avoid rechecking window status on every loop

This commit is contained in:
Eugene Pankov
2022-01-22 14:16:46 +01:00
parent 9df8a1b904
commit 53cbb8a7e3
2 changed files with 15 additions and 1 deletions

View File

@@ -303,6 +303,9 @@ export class Window {
this.window.on('enter-full-screen', () => this.send('host:window-enter-full-screen'))
this.window.on('leave-full-screen', () => this.send('host:window-leave-full-screen'))
this.window.on('maximize', () => this.send('host:window-maximized'))
this.window.on('unmaximize', () => this.send('host:window-unmaximized'))
this.window.on('close', event => {
if (!this.closing) {
event.preventDefault()

View File

@@ -15,6 +15,7 @@ export class ElectronHostWindow extends HostWindowService {
get isFullscreen (): boolean { return this._isFullscreen }
private _isFullscreen = false
private _isMaximized = false
constructor (
zone: NgZone,
@@ -47,6 +48,16 @@ export class ElectronHostWindow extends HostWindowService {
electron.ipcRenderer.on('host:became-main-window', () => zone.run(() => {
this.bootstrapData.isMainWindow = true
}))
electron.ipcRenderer.on('host:window-maximized', () => zone.run(() => {
this._isMaximized = true
}))
electron.ipcRenderer.on('host:window-unmaximized', () => zone.run(() => {
this._isMaximized = false
}))
this._isMaximized = this.getWindow().isMaximized()
}
getWindow (): BrowserWindow {
@@ -74,7 +85,7 @@ export class ElectronHostWindow extends HostWindowService {
}
isMaximized (): boolean {
return this.getWindow().isMaximized()
return this._isMaximized
}
toggleMaximize (): void {