Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/app/app.menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ function setupMenu() {
{ type: 'separator' },
{ role: 'resetZoom' },
{ role: 'zoomIn' },
// By default zoomIn works by "CommandOrControl + +" ("CommandOrControl + SHIFT + =")
// Hidden menu item adds zoomIn without SHIFT
{
role: 'zoomIn',
accelerator: 'CommandOrControl+=',
visible: false,
},
{ role: 'zoomOut' },
{ type: 'separator' },
{ role: 'togglefullscreen' },
Expand Down
38 changes: 38 additions & 0 deletions src/app/applyWheelZoom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* @copyright Copyright (c) 2023 Grigorii Shartsev <[email protected]>
*
* @author Grigorii Shartsev <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Enable zooming window by mouse wheel
*
* @param {import('electron').BrowserWindow} browserWindow - Browser window
*/
export function applyWheelZoom(browserWindow) {
browserWindow.webContents.on('zoom-changed', (event, zoomDirection) => {
const zoom = browserWindow.webContents.getZoomLevel()
// 0.5 level delta seems to be equivalent of "CTRL+" (zoomIn) and CTRL- (zoomOut) commands
const zoomDelta = 0.5 * (zoomDirection === 'in' ? 1 : -1)
const newZoom = zoom + zoomDelta
// Undocumented default limits for zoom level is [-8, 9] or [~23.25%, 515.97%]
if (newZoom >= -8 && newZoom <= 9) {
browserWindow.webContents.setZoomLevel(zoom + zoomDelta)
}
})
}
3 changes: 3 additions & 0 deletions src/talk/talk.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const {
windowOpenExternalLinkHandler,
willNavigateExternalLinkHandler,
} = require('../app/externalLinkHandlers.js')
const { applyWheelZoom } = require('../app/applyWheelZoom.js')

/**
* @return {import('electron').BrowserWindow}
Expand Down Expand Up @@ -64,6 +65,8 @@ function createTalkWindow() {
window.show()
})

applyWheelZoom(window)

window.loadURL(TALK_WINDOW_WEBPACK_ENTRY)

return window
Expand Down