Skip to content

[UI/Fix] Set zoom limits along with zoom level instead of zoom factor #3325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Changes from 2 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
17 changes: 10 additions & 7 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ async function initializeWindow(): Promise<BrowserWindow> {
})

ipcMain.on('setZoomFactor', async (event, zoomFactor) => {
mainWindow.webContents.setZoomFactor(
processZoomForScreen(parseFloat(zoomFactor))
)
const factor = processZoomForScreen(parseFloat(zoomFactor))
mainWindow.webContents.setZoomLevel(factor)
mainWindow.webContents.setVisualZoomLevelLimits(1, 1)
})

return mainWindow
Expand All @@ -276,9 +276,9 @@ const processZoomForScreen = (zoomFactor: number) => {
const screenSize = screen.getPrimaryDisplay().workAreaSize.width
if (screenSize < 1200) {
const extraDPIZoomIn = screenSize / 1200
return zoomFactor * extraDPIZoomIn
return (zoomFactor * extraDPIZoomIn - 1) / 0.2
} else {
return zoomFactor
return (zoomFactor - 1) / 0.2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of setting a zoom factor (like 1.2, 1.4, 0.8, etc), setZoomLevel expects an integer with increments of 0.2 zoom

so a zoom of 80% is 0.8 zoom factor so it's -1 for zoom level
120% is 1.2 zoom factor so it's 1 zoom level

}
}

Expand Down Expand Up @@ -448,9 +448,12 @@ if (!gotTheLock) {

// set initial zoom level after a moment, if set in sync the value stays as 1
setTimeout(() => {
const zoomFactor = configStore.get('zoomPercent', 100) / 100
const zoomFactor = processZoomForScreen(
configStore.get('zoomPercent', 100) / 100
)

mainWindow.webContents.setZoomFactor(processZoomForScreen(zoomFactor))
mainWindow.webContents.setZoomLevel(zoomFactor)
mainWindow.webContents.setVisualZoomLevelLimits(1, 1)
}, 200)

ipcMain.on('changeLanguage', async (event, language) => {
Expand Down