@@ -9,6 +9,7 @@ import { focusedBuilderWindow, getBuilderWindowById } from "./emain-builder";
99import { openBuilderWindow } from "./emain-ipc" ;
1010import { isDev , unamePlatform } from "./emain-platform" ;
1111import { clearTabCache } from "./emain-tabview" ;
12+ import { decreaseZoomLevel , increaseZoomLevel } from "./emain-util" ;
1213import {
1314 createNewWaveWindow ,
1415 createWorkspace ,
@@ -123,7 +124,11 @@ function makeEditMenu(fullConfig?: FullConfigType): Electron.MenuItemConstructor
123124 ] ;
124125}
125126
126- function makeFileMenu ( numWaveWindows : number , callbacks : AppMenuCallbacks , fullConfig : FullConfigType ) : Electron . MenuItemConstructorOptions [ ] {
127+ function makeFileMenu (
128+ numWaveWindows : number ,
129+ callbacks : AppMenuCallbacks ,
130+ fullConfig : FullConfigType
131+ ) : Electron . MenuItemConstructorOptions [ ] {
127132 const fileMenu : Electron . MenuItemConstructorOptions [ ] = [
128133 {
129134 label : "New Window" ,
@@ -242,25 +247,19 @@ function makeViewMenu(
242247 accelerator : "CommandOrControl+=" ,
243248 click : ( _ , window ) => {
244249 const wc = getWindowWebContents ( window ) ?? webContents ;
245- if ( wc == null ) {
246- return ;
250+ if ( wc ) {
251+ increaseZoomLevel ( wc ) ;
247252 }
248- const newZoom = Math . min ( 5 , wc . getZoomFactor ( ) + 0.2 ) ;
249- wc . setZoomFactor ( newZoom ) ;
250- wc . send ( "zoom-factor-change" , newZoom ) ;
251253 } ,
252254 } ,
253255 {
254256 label : "Zoom In (hidden)" ,
255257 accelerator : "CommandOrControl+Shift+=" ,
256258 click : ( _ , window ) => {
257259 const wc = getWindowWebContents ( window ) ?? webContents ;
258- if ( wc == null ) {
259- return ;
260+ if ( wc ) {
261+ increaseZoomLevel ( wc ) ;
260262 }
261- const newZoom = Math . min ( 5 , wc . getZoomFactor ( ) + 0.2 ) ;
262- wc . setZoomFactor ( newZoom ) ;
263- wc . send ( "zoom-factor-change" , newZoom ) ;
264263 } ,
265264 visible : false ,
266265 acceleratorWorksWhenHidden : true ,
@@ -270,25 +269,19 @@ function makeViewMenu(
270269 accelerator : "CommandOrControl+-" ,
271270 click : ( _ , window ) => {
272271 const wc = getWindowWebContents ( window ) ?? webContents ;
273- if ( wc == null ) {
274- return ;
272+ if ( wc ) {
273+ decreaseZoomLevel ( wc ) ;
275274 }
276- const newZoom = Math . max ( 0.2 , wc . getZoomFactor ( ) - 0.2 ) ;
277- wc . setZoomFactor ( newZoom ) ;
278- wc . send ( "zoom-factor-change" , newZoom ) ;
279275 } ,
280276 } ,
281277 {
282278 label : "Zoom Out (hidden)" ,
283279 accelerator : "CommandOrControl+Shift+-" ,
284280 click : ( _ , window ) => {
285281 const wc = getWindowWebContents ( window ) ?? webContents ;
286- if ( wc == null ) {
287- return ;
282+ if ( wc ) {
283+ decreaseZoomLevel ( wc ) ;
288284 }
289- const newZoom = Math . max ( 0.2 , wc . getZoomFactor ( ) - 0.2 ) ;
290- wc . setZoomFactor ( newZoom ) ;
291- wc . send ( "zoom-factor-change" , newZoom ) ;
292285 } ,
293286 visible : false ,
294287 acceleratorWorksWhenHidden : true ,
@@ -380,7 +373,11 @@ export function instantiateAppMenu(workspaceOrBuilderId?: string): Promise<elect
380373 ) ;
381374}
382375
383- export function makeAppMenu ( ) {
376+ // does not a set a menu on windows
377+ export function makeAndSetAppMenu ( ) {
378+ if ( unamePlatform === "win32" ) {
379+ return ;
380+ }
384381 fireAndForget ( async ( ) => {
385382 const menu = await instantiateAppMenu ( ) ;
386383 electron . Menu . setApplicationMenu ( menu ) ;
@@ -389,7 +386,7 @@ export function makeAppMenu() {
389386
390387waveEventSubscribe ( {
391388 eventType : "workspace:update" ,
392- handler : makeAppMenu ,
389+ handler : makeAndSetAppMenu ,
393390} ) ;
394391
395392function getWebContentsByWorkspaceOrBuilderId ( workspaceOrBuilderId : string ) : electron . WebContents {
0 commit comments