mirror of
https://github.com/desktop/desktop
synced 2024-10-31 11:07:25 +00:00
Calculate window state on event
This commit is contained in:
parent
39d9332501
commit
7c2562f0ac
1 changed files with 15 additions and 8 deletions
|
@ -61,12 +61,19 @@ export default class AppWindow {
|
|||
}
|
||||
|
||||
private registerWindowStateChangedEvents() {
|
||||
this.window.on('enter-full-screen', () => this.sendWindowStateEvent('full-screen'))
|
||||
this.window.on('leave-full-screen', () => this.sendWindowStateEvent(this.getWindowState()))
|
||||
this.window.on('maximize', () => this.sendWindowStateEvent('maximized'))
|
||||
this.window.on('minimize', () => this.sendWindowStateEvent('minimized'))
|
||||
this.window.on('unmaximize', () => this.sendWindowStateEvent('normal'))
|
||||
this.window.on('restore', () => this.sendWindowStateEvent('normal'))
|
||||
|
||||
const windowStateEvents = [
|
||||
'enter-full-screen',
|
||||
'leave-full-screen',
|
||||
'maximize',
|
||||
'minimize',
|
||||
'unmaximize',
|
||||
'restore'
|
||||
]
|
||||
|
||||
for (const eventName of windowStateEvents) {
|
||||
this.window.on(eventName, this.sendWindowStateEvent)
|
||||
}
|
||||
}
|
||||
|
||||
private getWindowState(): WindowState {
|
||||
|
@ -81,8 +88,8 @@ export default class AppWindow {
|
|||
}
|
||||
}
|
||||
|
||||
private sendWindowStateEvent(state: WindowState) {
|
||||
this.send('window-state-changed', state)
|
||||
private sendWindowStateEvent = () => {
|
||||
this.send('window-state-changed', this.getWindowState())
|
||||
}
|
||||
|
||||
public onClose(fn: () => void) {
|
||||
|
|
Loading…
Reference in a new issue