From 56dce1553757eae209d988d3a1a7f4ac162d80c1 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Mon, 9 Dec 2024 07:56:40 -0800 Subject: [PATCH] Desktop: Fixes #11444: Allow zooming in/out in secondary windows (#11467) --- packages/app-desktop/ElectronAppWrapper.ts | 8 ++++++++ packages/app-desktop/app.ts | 4 ++-- packages/app-desktop/bridge.ts | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) 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)); }