aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts')
-rw-r--r--packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts20
1 files changed, 15 insertions, 5 deletions
diff --git a/packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts b/packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts
index 2e64269..3118efc 100644
--- a/packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts
+++ b/packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts
@@ -18,7 +18,6 @@
18 * SPDX-License-Identifier: AGPL-3.0-only 18 * SPDX-License-Identifier: AGPL-3.0-only
19 */ 19 */
20 20
21import type { BrowserViewBounds } from '@sophie/shared';
22import { BrowserView } from 'electron'; 21import { BrowserView } from 'electron';
23 22
24import type Service from '../../../stores/Service'; 23import type Service from '../../../stores/Service';
@@ -39,7 +38,7 @@ export default class ElectronServiceView implements ServiceView {
39 readonly browserView: BrowserView; 38 readonly browserView: BrowserView;
40 39
41 constructor( 40 constructor(
42 service: Service, 41 private readonly service: Service,
43 resources: Resources, 42 resources: Resources,
44 partition: ElectronPartition, 43 partition: ElectronPartition,
45 private readonly parent: ElectronViewFactory, 44 private readonly parent: ElectronViewFactory,
@@ -56,6 +55,13 @@ export default class ElectronServiceView implements ServiceView {
56 }); 55 });
57 56
58 this.browserView.setBackgroundColor('#fff'); 57 this.browserView.setBackgroundColor('#fff');
58 this.browserView.setAutoResize({
59 width: true,
60 height: true,
61 });
62 // Util we first attach `browserView` to a `BrowserWindow`,
63 // `setBounds` calls will be ignored, so there's no point in callind `updateBounds` here.
64 // It will be called by `ElectronMainWindow` when we first attach this service to it.
59 65
60 const { webContents } = this.browserView; 66 const { webContents } = this.browserView;
61 67
@@ -191,13 +197,17 @@ export default class ElectronServiceView implements ServiceView {
191 this.browserView.webContents.toggleDevTools(); 197 this.browserView.webContents.toggleDevTools();
192 } 198 }
193 199
194 setBounds(bounds: BrowserViewBounds): void { 200 updateBounds(): void {
195 this.browserView.setBounds(bounds); 201 const { x, y, width, height, hasBounds } = this.service;
202 if (!hasBounds) {
203 return;
204 }
205 this.browserView.setBounds({ x, y, width, height });
196 } 206 }
197 207
198 dispose(): void { 208 dispose(): void {
199 this.parent.unregisterServiceView(this.webContentsId);
200 setImmediate(() => { 209 setImmediate(() => {
210 this.parent.unregisterServiceView(this.webContentsId);
201 // Undocumented electron API, see e.g., https://github.com/electron/electron/issues/29626 211 // Undocumented electron API, see e.g., https://github.com/electron/electron/issues/29626
202 ( 212 (
203 this.browserView.webContents as unknown as { destroy(): void } 213 this.browserView.webContents as unknown as { destroy(): void }