From 08e94b9f5571130d26ff53a652bf97f66c56b109 Mon Sep 17 00:00:00 2001 From: Tasos Boulis Date: Thu, 1 Dec 2022 19:44:47 +0200 Subject: [PATCH] [MM-48574] Fixed issue on windows where in some cases window resize does not work (#2441) * Fixed issue on windows where in some cases window resize does not work * Use silly instead of debug for window resizing functions --- src/main/views/modalManager.ts | 2 +- src/main/windows/windowManager.ts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/views/modalManager.ts b/src/main/views/modalManager.ts index c36ce31a..9102ec0b 100644 --- a/src/main/views/modalManager.ts +++ b/src/main/views/modalManager.ts @@ -131,7 +131,7 @@ export class ModalManager { } handleResizeModal = (event: IpcMainEvent, bounds: Electron.Rectangle) => { - log.debug('ModalManager.handleResizeModal', bounds); + log.debug('ModalManager.handleResizeModal', {bounds, modalQueueLength: this.modalQueue.length}); if (this.modalQueue.length) { const currentModal = this.modalQueue[0]; diff --git a/src/main/windows/windowManager.ts b/src/main/windows/windowManager.ts index 1bb67737..294bfecd 100644 --- a/src/main/windows/windowManager.ts +++ b/src/main/windows/windowManager.ts @@ -264,8 +264,17 @@ export class WindowManager { return; } + /** + * Fixes an issue on win11 related to Snap where the first "will-resize" event would return the same bounds + * causing the "resize" event to not fire + */ + const prevBounds = this.getBounds(); + if (prevBounds.height === newBounds.height && prevBounds.width === newBounds.width) { + return; + } + if (this.isResizing && this.viewManager.loadingScreenState === LoadingScreenState.HIDDEN && this.viewManager.getCurrentView()) { - log.silly('prevented resize'); + log.debug('prevented resize'); event.preventDefault(); return; } @@ -297,6 +306,8 @@ export class WindowManager { } private throttledWillResize = (newBounds: Electron.Rectangle) => { + log.silly('WindowManager.throttledWillResize', {newBounds}); + this.isResizing = true; this.setCurrentViewBounds(newBounds); } @@ -324,6 +335,8 @@ export class WindowManager { }; setCurrentViewBounds = (bounds: {width: number; height: number}) => { + log.debug('WindowManager.setCurrentViewBounds', {bounds}); + const currentView = this.viewManager?.getCurrentView(); if (currentView) { const adjustedBounds = getAdjustedWindowBoundaries(bounds.width, bounds.height, shouldHaveBackBar(currentView.tab.url, currentView.view.webContents.getURL()));