diff --git a/packages/app-desktop/ElectronAppWrapper.ts b/packages/app-desktop/ElectronAppWrapper.ts index 143f26647..9c47ac820 100644 --- a/packages/app-desktop/ElectronAppWrapper.ts +++ b/packages/app-desktop/ElectronAppWrapper.ts @@ -99,6 +99,11 @@ export default class ElectronAppWrapper { return null; } + public allAppWindows() { + const allWindowIds = [...this.secondaryWindows_.keys(), defaultWindowId]; + return allWindowIds.map(id => this.windowById(id)); + } + public env() { return this.env_; } @@ -358,6 +363,9 @@ export default class ElectronAppWrapper { const electronWindowId = window?.id; this.secondaryWindows_.set(windowId, { electronId: electronWindowId }); + // Match the main window's zoom: + window.webContents.setZoomFactor(this.mainWindow().webContents.getZoomFactor()); + window.once('close', () => { this.secondaryWindows_.delete(windowId); diff --git a/packages/app-desktop/app.ts b/packages/app-desktop/app.ts index 6a91b1126..69480c1a9 100644 --- a/packages/app-desktop/app.ts +++ b/packages/app-desktop/app.ts @@ -29,7 +29,7 @@ import { reg } from '@joplin/lib/registry'; const packageInfo: PackageInfo = require('./packageInfo.js'); import DecryptionWorker from '@joplin/lib/services/DecryptionWorker'; import ClipperServer from '@joplin/lib/ClipperServer'; -import { ipcRenderer, webFrame } from 'electron'; +import { ipcRenderer } from 'electron'; const Menu = bridge().Menu; const PluginManager = require('@joplin/lib/services/PluginManager'); import RevisionService from '@joplin/lib/services/RevisionService'; @@ -152,7 +152,7 @@ class Application extends BaseApplication { } if (action.type === 'SETTING_UPDATE_ONE' && action.key === 'windowContentZoomFactor' || action.type === 'SETTING_UPDATE_ALL') { - webFrame.setZoomFactor(Setting.value('windowContentZoomFactor') / 100); + bridge().setZoomFactor(Setting.value('windowContentZoomFactor') / 100); } if (action.type === 'SETTING_UPDATE_ONE' && action.key === 'linking.extraAllowedExtensions' || action.type === 'SETTING_UPDATE_ALL') { diff --git a/packages/app-desktop/bridge.ts b/packages/app-desktop/bridge.ts index 0a25fffe8..f6f31e036 100644 --- a/packages/app-desktop/bridge.ts +++ b/packages/app-desktop/bridge.ts @@ -285,6 +285,13 @@ export class Bridge { this.switchToWindow(defaultWindowId); } + // zoom should be in the range [0..1] + public setZoomFactor(zoom: number) { + for (const window of this.electronWrapper_.allAppWindows()) { + window.webContents.setZoomFactor(zoom); + } + } + public showItemInFolder(fullPath: string) { return require('electron').shell.showItemInFolder(toSystemSlashes(fullPath)); }