diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-03-07 13:01:47 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-03-07 13:15:36 +0100 |
| commit | 802b1ccec0cb280d75c6ff11bc0dae1115c5831d (patch) | |
| tree | d551d049771fa97b39a167fc5237b7f72c1451b9 | |
| parent | b411e624f0c697efa4cdb85489af1bdbf18281dc (diff) | |
| download | mullvadvpn-802b1ccec0cb280d75c6ff11bc0dae1115c5831d.tar.xz mullvadvpn-802b1ccec0cb280d75c6ff11bc0dae1115c5831d.zip | |
Update window position on display changes
| -rw-r--r-- | app/main.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/app/main.js b/app/main.js index 4a25a4d8fc..85003385ee 100644 --- a/app/main.js +++ b/app/main.js @@ -394,11 +394,14 @@ const appDelegate = { } }, + _updateWindowPosition: (window: BrowserWindow, tray: Tray) => { + const { x, y } = appDelegate._getWindowPosition(window, tray); + window.setPosition(x, y, false); + }, + _showWindow: (window: BrowserWindow, tray: ?Tray) => { - // position window based on tray icon location if(tray) { - const { x, y } = appDelegate._getWindowPosition(window, tray); - window.setPosition(x, y, false); + appDelegate._updateWindowPosition(window, tray); } window.show(); @@ -485,6 +488,13 @@ const appDelegate = { tray.setToolTip('Mullvad VPN'); tray.on('click', () => appDelegate._toggleWindow(window, tray)); + // add display metrics change handler + electron.screen.addListener('display-metrics-changed', (_event, _display, changedMetrics) => { + if(changedMetrics.includes('workArea') && window.isVisible()) { + appDelegate._updateWindowPosition(window, tray); + } + }); + // add IPC handler to change tray icon from renderer const trayIconManager = new TrayIconManager(tray, 'unsecured'); ipcMain.on('changeTrayIcon', (_: Event, type: TrayIconType) => trayIconManager.iconType = type); |
