Track zoom factor changes through IPC
This commit is contained in:
parent
3e18a8a337
commit
0793aa6b43
5 changed files with 66 additions and 27 deletions
22
main.js
22
main.js
|
@ -310,6 +310,27 @@ function handleCommonWindowEvents(window) {
|
|||
console.error(`Preload error in ${preloadPath}: `, error.message);
|
||||
});
|
||||
|
||||
// Works only for mainWindow because it has `enablePreferredSizeMode`
|
||||
let lastZoomFactor = window.webContents.getZoomFactor();
|
||||
const onZoomChanged = () => {
|
||||
const zoomFactor = mainWindow.webContents.getZoomFactor();
|
||||
if (lastZoomFactor === zoomFactor) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.webContents) {
|
||||
window.webContents.send('callbacks:call:setPassiveZoomFactor', [
|
||||
zoomFactor,
|
||||
]);
|
||||
if (settingsWindow && settingsWindow.webContents) {
|
||||
settingsWindow.webContents.send('render');
|
||||
}
|
||||
}
|
||||
|
||||
lastZoomFactor = zoomFactor;
|
||||
};
|
||||
window.webContents.on('preferred-size-changed', onZoomChanged);
|
||||
|
||||
nativeThemeNotifier.addWindow(window);
|
||||
}
|
||||
|
||||
|
@ -386,6 +407,7 @@ async function createWindow() {
|
|||
nativeWindowOpen: true,
|
||||
spellcheck: await getSpellCheckSetting(),
|
||||
backgroundThrottling: false,
|
||||
enablePreferredSizeMode: true,
|
||||
},
|
||||
icon: windowIcon,
|
||||
..._.pick(windowConfig, ['autoHideMenuBar', 'width', 'height', 'x', 'y']),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue