summaryrefslogtreecommitdiffhomepage
path: root/gui/src/main/window-controller.ts
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-11-09 18:11:46 +0100
committerOskar Nyberg <oskar@mullvad.net>2020-11-19 11:22:02 +0100
commit585f019300df75cdac366a7ecbdf7f9b8184cce1 (patch)
tree9875e6ad66d1394b23235297f5727eb097108f24 /gui/src/main/window-controller.ts
parent9790676f189a5c68c9478e8561e4911a6926b932 (diff)
downloadmullvadvpn-585f019300df75cdac366a7ecbdf7f9b8184cce1.tar.xz
mullvadvpn-585f019300df75cdac366a7ecbdf7f9b8184cce1.zip
Adjust app to handle window mode
Diffstat (limited to 'gui/src/main/window-controller.ts')
-rw-r--r--gui/src/main/window-controller.ts26
1 files changed, 21 insertions, 5 deletions
diff --git a/gui/src/main/window-controller.ts b/gui/src/main/window-controller.ts
index 69457a63fa..4c4b744b79 100644
--- a/gui/src/main/window-controller.ts
+++ b/gui/src/main/window-controller.ts
@@ -133,6 +133,7 @@ class AttachedToTrayWindowPositioning implements IWindowPositioning {
export default class WindowController {
private width: number;
private height: number;
+ private windowValue: BrowserWindow;
private webContentsValue: WebContents;
private windowPositioning: IWindowPositioning;
private isWindowReady = false;
@@ -145,20 +146,35 @@ export default class WindowController {
return this.webContentsValue;
}
- constructor(private windowValue: BrowserWindow, tray: Tray) {
+ constructor(windowValue: BrowserWindow, private tray: Tray, unpinnedWindow: boolean) {
const [width, height] = windowValue.getSize();
this.width = width;
this.height = height;
+ this.windowValue = windowValue;
this.webContentsValue = windowValue.webContents;
- this.windowPositioning =
- process.platform === 'linux'
- ? new StandaloneWindowPositioning()
- : new AttachedToTrayWindowPositioning(tray);
+ this.windowPositioning = unpinnedWindow
+ ? new StandaloneWindowPositioning()
+ : new AttachedToTrayWindowPositioning(tray);
this.installDisplayMetricsHandler();
this.installWindowReadyHandlers();
}
+ public replaceWindow(window: BrowserWindow, unpinnedWindow: boolean) {
+ this.window.removeAllListeners();
+ this.window.destroy();
+
+ this.windowValue = window;
+ this.webContentsValue = window.webContents;
+
+ this.windowPositioning = unpinnedWindow
+ ? new StandaloneWindowPositioning()
+ : new AttachedToTrayWindowPositioning(this.tray);
+
+ this.updatePosition();
+ this.notifyUpdateWindowShape();
+ }
+
public show(whenReady = true) {
if (whenReady) {
this.executeWhenWindowIsReady(() => this.showImmediately());