feat(desktop): custom zoom shortcuts at half default step - #37894
Merged
Conversation
Replace Electron's built-in zoomIn/zoomOut/resetZoom menu roles with custom implementations that use a 0.1 zoom-level step instead of Chromium's default 0.2. This makes Ctrl/Cmd + +/-0 zoom feel more granular and less jumpy. Also adds installZoomShortcuts() which intercepts the keyboard shortcuts via before-input-event. This is necessary on Linux/Windows where the application menu is set to null, so Chromium's default handler would otherwise apply the full 0.2 step.
Contributor
🔎 Lint report:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds custom Ctrl/Cmd + +/-/0 zoom handling to the desktop Electron app that uses half the default zoom step (0.1 instead of Chromium's built-in 0.2 per keypress). This makes zooming feel more granular and less jumpy.
The default Electron
zoomIn/zoomOut/resetZoommenu roles and Chromium's built-in keyboard handler both use a 0.2 zoom-level step. This PR replaces them with explicitsetZoomLevel()calls that step by 0.1, giving users finer control.Type of Change
Changes Made
apps/desktop/electron/main.cjs— Replaced{ role: 'resetZoom' },{ role: 'zoomIn' },{ role: 'zoomOut' }View menu items with custom click handlers that usewebContents.setZoomLevel()with a 0.1 step (clamped to ±9)apps/desktop/electron/main.cjs— AddedinstallZoomShortcuts(window)that intercepts Ctrl/Cmd +=/+/-/0viabefore-input-eventand applies the same 0.1 step. Required on Linux/Windows where the application menu isnulland Chromium would otherwise handle the shortcut with its default 0.2 step.apps/desktop/electron/main.cjs— WiredinstallZoomShortcuts(mainWindow)into the window setup alongside the otherinstall*calls.How to Test
hermes --desktopor from the built electron package)Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A