summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/index.ts1
-rw-r--r--gui/src/main/window-controller.ts26
2 files changed, 17 insertions, 10 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 3a7a6f1073..5e3b28b342 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -422,7 +422,6 @@ 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 b01fa90734..c7ab18b5f7 100644
--- a/gui/src/main/window-controller.ts
+++ b/gui/src/main/window-controller.ts
@@ -156,19 +156,24 @@ export default class WindowController {
: new AttachedToTrayWindowPositioning(tray);
this.installDisplayMetricsHandler();
+ this.installHideHandler();
}
- public replaceWindow(window: BrowserWindow, unpinnedWindow: boolean) {
- this.window?.removeAllListeners();
+ public replaceWindow(windowValue: BrowserWindow, unpinnedWindow: boolean) {
this.window?.destroy();
- this.windowValue = window;
- this.webContentsValue = window.webContents;
+ const [width, height] = windowValue.getSize();
+ this.width = width;
+ this.height = height;
+ this.windowValue = windowValue;
+ this.webContentsValue = windowValue.webContents;
this.windowPositioning = unpinnedWindow
? new StandaloneWindowPositioning()
: new AttachedToTrayWindowPositioning(this.tray);
+ this.installDisplayMetricsHandler();
+ this.installHideHandler();
this.updatePosition();
}
@@ -196,10 +201,6 @@ export default class WindowController {
return this.window?.isVisible() ?? false;
}
- public dispose() {
- this.windowPositioningScheduler.cancel();
- }
-
public updatePosition() {
if (this.window) {
const { x, y } = this.windowPositioning.getPosition(this.window);
@@ -209,6 +210,11 @@ export default class WindowController {
this.notifyUpdateWindowShape();
}
+ private installHideHandler() {
+ this.window?.addListener('hide', () => this.windowPositioningScheduler.cancel());
+ this.window?.addListener('closed', () => this.windowPositioningScheduler.cancel());
+ }
+
private showImmediately() {
const window = this.window;
@@ -258,7 +264,9 @@ export default class WindowController {
) => {
if (changedMetrics.includes('workArea') && this.window?.isVisible()) {
this.onWorkAreaSizeChange();
- this.windowPositioningScheduler.schedule(() => this.onWorkAreaSizeChange(), 500);
+ if (process.platform === 'win32') {
+ this.windowPositioningScheduler.schedule(() => this.onWorkAreaSizeChange(), 500);
+ }
}
// On linux, the window won't be properly rescaled back to it's original