feat(desktop): support Ctrl/Cmd + mouse wheel zoom - #40414
Conversation
Add the standard desktop/browser zoom gesture: Ctrl (Windows/Linux) or Cmd (macOS) + mouse wheel up/down to zoom in/out. Implementation: - Inject a lightweight wheel event listener into the renderer via executeJavaScript on dom-ready and did-finish-load - Listener detects Ctrl/Cmd + wheel, prevents default scroll, and sends a zoom delta over IPC (hermes:zoom:adjust) - Main process clamps zoom level to [-9, 9] with 0.1 step (matching the existing keyboard zoom step from installZoomShortcuts) Closes NousResearch#40295
|
Thanks for the useful desktop ergonomics contribution. The gesture remains worth salvaging, but this implementation needs a current-main port. Problems
Suggested changes
Automated hermes-sweeper review. |
Ground-truth reapply of PR #40414 by @liuhao1024. The original branch predates the ts-ify migration and implemented the gesture by injecting a DOM wheel listener via executeJavaScript + a new IPC channel. Current Electron surfaces the modifier+wheel gesture natively as the main-process webContents 'zoom-changed' event, so the salvage uses that instead: no renderer injection, no new preload surface, no new IPC channel. The handler routes through setAndPersistZoomLevel — the same persist+notify funnel as the keyboard shortcuts — so wheel zoom uses the same 0.1 half-step, persists to zoom-state.json across restarts, and keeps the settings Scale control in sync. Session windows get the gesture automatically via wireCommonWindowHandlers; the pet overlay stays opted out via zoomWiringForWindowKind.
|
Merged via PR #67029 (#67029) — the Ctrl/Cmd + wheel zoom gesture is on main with your authorship preserved via rebase-merge. Thanks for the contribution and the clear writeup! One implementation note: your branch predated the desktop TypeScript migration, so the change was reapplied under your authorship rather than cherry-picked — and in the process we found Electron now surfaces the modifier+wheel gesture natively as the main-process Closing this PR in favor of the merged salvage. Thanks again! |
Ground-truth reapply of PR NousResearch#40414 by @liuhao1024. The original branch predates the ts-ify migration and implemented the gesture by injecting a DOM wheel listener via executeJavaScript + a new IPC channel. Current Electron surfaces the modifier+wheel gesture natively as the main-process webContents 'zoom-changed' event, so the salvage uses that instead: no renderer injection, no new preload surface, no new IPC channel. The handler routes through setAndPersistZoomLevel — the same persist+notify funnel as the keyboard shortcuts — so wheel zoom uses the same 0.1 half-step, persists to zoom-state.json across restarts, and keeps the settings Scale control in sync. Session windows get the gesture automatically via wireCommonWindowHandlers; the pet overlay stays opted out via zoomWiringForWindowKind.
Summary
Adds the standard desktop/browser zoom gesture: Ctrl (Windows/Linux) or Cmd (macOS) + mouse wheel up/down to zoom in/out.
This is the most common zoom gesture in desktop applications and browsers. Hermes Desktop already supports keyboard shortcuts (
Ctrl/Cmd + +/-/0) and View menu zoom actions, but this gesture was missing.Implementation
main.cjs):installWheelZoom()injects a lightweight wheel event listener into the renderer viaexecuteJavaScriptondom-readyanddid-finish-loadCtrl/Cmd+ wheel, callse.preventDefault()to block page scroll, sends a zoom delta over IPC (hermes:zoom:adjust)[-9, 9]with0.1step — matching the existing keyboard zoom step frominstallZoomShortcutspreload.cjs): exposeszoomAdjust(delta)viaipcRenderer.sendglobal.d.ts): addszoomAdjust?: (delta: number) => voidto thehermesDesktopinterfaceBehavior
Testing
did-finish-load)Closes #40295