@@ -12,16 +12,36 @@ const MinZoomLevel = 0.4;
1212const MaxZoomLevel = 2.6 ;
1313const ZoomDelta = 0.2 ;
1414
15+ // Note: Chromium automatically syncs zoom factor across all WebContents
16+ // sharing the same origin/session, so we only need to notify renderers
17+ // to update their CSS/state — not call setZoomFactor on each one.
18+ // We broadcast to all WebContents (including devtools, webviews, etc.) but
19+ // that is safe because "zoom-factor-change" is a custom app-defined event
20+ // that only our renderers listen to; unrecognized IPC messages are ignored.
21+ function broadcastZoomFactorChanged ( newZoomFactor : number ) : void {
22+ for ( const wc of electron . webContents . getAllWebContents ( ) ) {
23+ if ( wc . isDestroyed ( ) ) {
24+ continue ;
25+ }
26+ wc . send ( "zoom-factor-change" , newZoomFactor ) ;
27+ }
28+ }
29+
1530export function increaseZoomLevel ( webContents : electron . WebContents ) : void {
1631 const newZoom = Math . min ( MaxZoomLevel , webContents . getZoomFactor ( ) + ZoomDelta ) ;
1732 webContents . setZoomFactor ( newZoom ) ;
18- webContents . send ( "zoom-factor-change" , newZoom ) ;
33+ broadcastZoomFactorChanged ( newZoom ) ;
1934}
2035
2136export function decreaseZoomLevel ( webContents : electron . WebContents ) : void {
2237 const newZoom = Math . max ( MinZoomLevel , webContents . getZoomFactor ( ) - ZoomDelta ) ;
2338 webContents . setZoomFactor ( newZoom ) ;
24- webContents . send ( "zoom-factor-change" , newZoom ) ;
39+ broadcastZoomFactorChanged ( newZoom ) ;
40+ }
41+
42+ export function resetZoomLevel ( webContents : electron . WebContents ) : void {
43+ webContents . setZoomFactor ( 1 ) ;
44+ broadcastZoomFactorChanged ( 1 ) ;
2545}
2646
2747export function getElectronExecPath ( ) : string {
0 commit comments