Add ZoomFactorService to keep windows in sync

This commit is contained in:
Jamie Kyle 2023-12-22 12:27:49 -08:00 committed by GitHub
parent 5354b23d08
commit 95842c6e0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 223 additions and 101 deletions

View file

@ -1,7 +1,6 @@
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { webFrame } from 'electron';
import { isNumber, throttle, groupBy } from 'lodash';
import { render } from 'react-dom';
import { batch as batchDispatch } from 'react-redux';
@ -819,14 +818,13 @@ export async function startApp(): Promise<void> {
},
});
const zoomFactor = window.Events.getZoomFactor();
webFrame.setZoomFactor(zoomFactor);
const zoomFactor = await window.Events.getZoomFactor();
document.body.style.setProperty('--zoom-factor', zoomFactor.toString());
window.addEventListener('resize', () => {
window.Events.onZoomFactorChange(newZoomFactor => {
document.body.style.setProperty(
'--zoom-factor',
webFrame.getZoomFactor().toString()
newZoomFactor.toString()
);
});