summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/main.js16
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);