Fix main window eager get zoom setting

This commit is contained in:
ayumi-signal 2023-10-04 10:24:41 -07:00 committed by GitHub
parent c1f4bac802
commit 68185606e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -563,19 +563,24 @@ function handleCommonWindowEvents(
mainWindow.webContents.setZoomFactor(zoomFactor);
}
};
window.once('ready-to-show', async () => {
// Workaround to apply zoomFactor because webPreferences does not handle it correctly
// https://github.com/electron/electron/issues/10572
const zoomFactor =
(await settingsChannel?.getSettingFromMainWindow('zoomFactor')) ?? 1;
window.webContents.setZoomFactor(zoomFactor);
});
window.on('show', () => {
// Install handler here after we init zoomFactor otherwise an initial
// preferred-size-changed event emits with an undesired zoomFactor.
window.webContents.on('preferred-size-changed', onZoomChanged);
});
// Workaround to apply zoomFactor because webPreferences does not handle it
// https://github.com/electron/electron/issues/10572
// But main window emits ready-to-show before window.Events is available
// so set main window zoom in background.ts
if (window !== mainWindow) {
window.once('ready-to-show', async () => {
const zoomFactor =
(await settingsChannel?.getSettingFromMainWindow('zoomFactor')) ?? 1;
window.webContents.setZoomFactor(zoomFactor);
});
}
nativeThemeNotifier.addWindow(window);
if (titleBarOverlay) {