summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-10-26 13:04:25 +0200
committerOskar Nyberg <oskar@mullvad.net>2021-10-27 15:24:08 +0200
commit8c64002fbeac3857115a2c150cc625490dbe0bec (patch)
tree51e19eac57a72a1cd9dc6686936a0d58257087be /gui/src
parentc9e46c7126f2ca701953cba07c7b8e1b1136b15b (diff)
downloadmullvadvpn-8c64002fbeac3857115a2c150cc625490dbe0bec.tar.xz
mullvadvpn-8c64002fbeac3857115a2c150cc625490dbe0bec.zip
Check tray prosition multiple times after screen resize
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/index.ts1
-rw-r--r--gui/src/main/window-controller.ts16
2 files changed, 15 insertions, 2 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 29baab992a..684956a92c 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -422,6 +422,7 @@ class ApplicationMain {
}
this.trayIconController?.dispose();
+ this.windowController?.dispose();
}
private detectLocale(): string {
diff --git a/gui/src/main/window-controller.ts b/gui/src/main/window-controller.ts
index 298f767fb5..81b5e5d130 100644
--- a/gui/src/main/window-controller.ts
+++ b/gui/src/main/window-controller.ts
@@ -1,6 +1,7 @@
import { BrowserWindow, Display, screen, Tray, WebContents } from 'electron';
import { IpcMainEventChannel } from './ipc-event-channel';
import { IWindowShapeParameters } from '../shared/ipc-types';
+import { Scheduler } from '../shared/scheduler';
interface IPosition {
x: number;
@@ -134,6 +135,8 @@ export default class WindowController {
private webContentsValue: WebContents;
private windowPositioning: IWindowPositioning;
+ private windowPositioningScheduler = new Scheduler();
+
get window(): BrowserWindow | undefined {
return this.windowValue.isDestroyed() ? undefined : this.windowValue;
}
@@ -194,6 +197,10 @@ export default class WindowController {
return this.window?.isVisible() ?? false;
}
+ public dispose() {
+ this.windowPositioningScheduler.cancel();
+ }
+
private showImmediately() {
const window = this.window;
@@ -251,8 +258,8 @@ export default class WindowController {
changedMetrics: string[],
) => {
if (changedMetrics.includes('workArea') && this.window?.isVisible()) {
- this.updatePosition();
- this.notifyUpdateWindowShape();
+ this.onWorkAreaSizeChange();
+ this.windowPositioningScheduler.schedule(() => this.onWorkAreaSizeChange(), 500);
}
// On linux, the window won't be properly rescaled back to it's original
@@ -263,6 +270,11 @@ export default class WindowController {
}
};
+ private onWorkAreaSizeChange() {
+ this.updatePosition();
+ this.notifyUpdateWindowShape();
+ }
+
private forceResizeWindow() {
this.window?.setSize(this.width, this.height);
}