From adde4b2b9f439bdb9a9d1a34ec436bda5a147510 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Mon, 9 May 2022 16:27:09 +0200 Subject: [PATCH] [MM-44022] Switch to using current BrowserView for determining window bounds for URL view (#2087) (#2091) (cherry picked from commit ebf5897f996a29efce4abe95afac25852a0d76a0) Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> --- src/main/views/viewManager.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/views/viewManager.ts b/src/main/views/viewManager.ts index e644c420..696f6e27 100644 --- a/src/main/views/viewManager.ts +++ b/src/main/views/viewManager.ts @@ -6,7 +6,7 @@ import {BrowserViewConstructorOptions} from 'electron/main'; import {Tab, TeamWithTabs} from 'types/config'; -import {SECOND} from 'common/utils/constants'; +import {SECOND, TAB_BAR_HEIGHT} from 'common/utils/constants'; import { UPDATE_TARGET_URL, LOAD_SUCCESS, @@ -322,7 +322,7 @@ export class ViewManager { const localURL = getLocalURLString('urlView.html', query); urlView.webContents.loadURL(localURL); this.mainWindow.addBrowserView(urlView); - const boundaries = this.mainWindow.getBounds(); + const boundaries = this.views.get(this.currentView || '')?.view.getBounds() ?? this.mainWindow.getBounds(); const hideView = () => { delete this.urlViewCancel; @@ -338,12 +338,15 @@ export class ViewManager { const adjustWidth = (event: IpcMainEvent, width: number) => { log.silly('showURLView.adjustWidth', width); - urlView.setBounds({ + const bounds = { x: 0, - y: boundaries.height - URL_VIEW_HEIGHT, + y: (boundaries.height + TAB_BAR_HEIGHT) - URL_VIEW_HEIGHT, width: width + 5, // add some padding to ensure that we don't cut off the border height: URL_VIEW_HEIGHT, - }); + }; + + log.silly('showURLView setBounds', boundaries, bounds); + urlView.setBounds(bounds); }; ipcMain.on(UPDATE_URL_VIEW_WIDTH, adjustWidth);