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
5 changes: 3 additions & 2 deletions apps/desktop/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6951,8 +6951,9 @@ function wireCommonWindowHandlers(win, { zoom = true }: { zoom?: boolean } = {})

if (zoom) {
installZoomShortcuts(win)
// Re-apply persisted zoom on show/restore (Windows drops webContents zoom on
// minimize/restore) and on first load (reloads / crash recovery).
// Re-apply persisted zoom on show/restore/cross-display move (Windows can
// drop webContents zoom after minimize or a monitor-scale change) and on
// first load (reloads / crash recovery).
installZoomReassertOnWindowEvents(win, () => restorePersistedZoomLevel(win))
win.webContents.once('did-finish-load', () => restorePersistedZoomLevel(win))
}
Expand Down
5 changes: 3 additions & 2 deletions apps/desktop/electron/zoom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test('extreme percentages clamp to the level bounds', () => {
assert.equal(percentToZoomLevel(1_000_000), 9)
})

test('installZoomReassertOnWindowEvents wires show and restore', () => {
test('installZoomReassertOnWindowEvents wires show, restore, and cross-display moves', () => {
const handlers = new Map()

const win = {
Expand All @@ -82,7 +82,8 @@ test('installZoomReassertOnWindowEvents wires show and restore', () => {
assert.deepEqual([...handlers.keys()], [...ZOOM_REASSERT_WINDOW_EVENTS])
handlers.get('show')()
handlers.get('restore')()
assert.equal(calls, 2)
handlers.get('moved')()
assert.equal(calls, 3)
})

test('installZoomReassertOnWindowEvents skips destroyed windows', () => {
Expand Down
5 changes: 3 additions & 2 deletions apps/desktop/electron/zoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ export function applyZoomLevel(webContents, level) {
}

// Chromium on Windows can drop webContents zoom when a BrowserWindow is minimized
// and restored. Re-apply the persisted level on these lifecycle transitions.
export const ZOOM_REASSERT_WINDOW_EVENTS = ['show', 'restore']
// and restored or crosses onto a monitor with different display scaling. Re-apply
// the persisted level after each completed lifecycle transition.
export const ZOOM_REASSERT_WINDOW_EVENTS = ['show', 'restore', 'moved']

export function installZoomReassertOnWindowEvents(win, reassert) {
if (!win?.on) {
Expand Down
Loading