diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-10-26 16:43:19 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-11-02 13:28:42 +0100 |
| commit | 1f59aadd098e67678ef770d6a5a4e75c2ffe853c (patch) | |
| tree | 872bdf898518dce904de6b3ddfea9438f07c832f /gui/src/main | |
| parent | 5a0e8ad01d8bc19c46cb7c2263513c1d7129a6a1 (diff) | |
| download | mullvadvpn-1f59aadd098e67678ef770d6a5a4e75c2ffe853c.tar.xz mullvadvpn-1f59aadd098e67678ef770d6a5a4e75c2ffe853c.zip | |
Add margin on Windows 11
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/window-controller.ts | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gui/src/main/window-controller.ts b/gui/src/main/window-controller.ts index c7ab18b5f7..cdb7102afb 100644 --- a/gui/src/main/window-controller.ts +++ b/gui/src/main/window-controller.ts @@ -1,7 +1,8 @@ import { BrowserWindow, Display, screen, Tray, WebContents } from 'electron'; -import { IpcMainEventChannel } from './ipc-event-channel'; +import os from 'os'; import { IWindowShapeParameters } from '../shared/ipc-types'; import { Scheduler } from '../shared/scheduler'; +import { IpcMainEventChannel } from './ipc-event-channel'; interface IPosition { x: number; @@ -13,6 +14,11 @@ interface IWindowPositioning { getWindowShapeParameters(window: BrowserWindow): IWindowShapeParameters; } +// Tray applications are positioned aproximately 10px from the tray in Windows 11. Windows 11 has +// the internal version 10.0.22000+. +const MARGIN = + process.platform === 'win32' && parseInt(os.release().split('.').at(-1)!) >= 22000 ? 10 : 0; + class StandaloneWindowPositioning implements IWindowPositioning { public getPosition(window: BrowserWindow): IPosition { const windowBounds = window.getBounds(); @@ -59,21 +65,21 @@ class AttachedToTrayWindowPositioning implements IWindowPositioning { switch (placement) { case 'top': x = trayBounds.x + (trayBounds.width - windowBounds.width) * 0.5; - y = workArea.y; + y = workArea.y + MARGIN; break; case 'bottom': x = trayBounds.x + (trayBounds.width - windowBounds.width) * 0.5; - y = workArea.y + workArea.height - windowBounds.height; + y = workArea.y + workArea.height - windowBounds.height - MARGIN; break; case 'left': - x = workArea.x; + x = workArea.x + MARGIN; y = trayBounds.y + (trayBounds.height - windowBounds.height) * 0.5; break; case 'right': - x = workArea.width - windowBounds.width; + x = workArea.width - windowBounds.width - MARGIN; y = trayBounds.y + (trayBounds.height - windowBounds.height) * 0.5; break; |
