Skip to content

Commit

Permalink
Fix empty space and zoom in HTML mail view
Browse files Browse the repository at this point in the history
- zoom in email content dependes both on window zoom and settings
  zoomFactor
- email contents window in HTML mail view positioning is fixed
- resolves #4050
  • Loading branch information
maxphilippov committed Aug 5, 2024
1 parent 72bb581 commit a6694b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
- fix composite emoji in text avatar #4038
- fix "Password and Account" dialog not indicating invalid credentials, making it seem that you can change password like this #4032
- fix empty context menu and unneccessary separators in HTML mail view #4053
- fix HTML email view empty space before email content #4052
- fix HTML email content not being zoomed #4052
- fix Icon preview of latest WebXDC displayed when summary is reaction event #4062
- fix stretched summaryPreviewIcon #4064

Expand Down
23 changes: 18 additions & 5 deletions src/main/windows/html_email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ export function openHtmlEmailWindow(
window.show()
})

window.once('focus', () => {
window.webContents.setZoomFactor(DesktopSettings.state.zoomFactor)
})
window.on('close', () => {
context_menu_handle?.()
delete open_windows[window_id]
Expand Down Expand Up @@ -218,6 +215,9 @@ export function openHtmlEmailWindow(
window
)
window.setBrowserView(sandboxedView)
sandboxedView.webContents.setZoomFactor(
DesktopSettings.state.zoomFactor * (1.2 ^ window.webContents.getZoomLevel())
)
let context_menu_handle = createContextMenu(window, sandboxedView.webContents)

window.webContents.ipc.handle('html-view:more-menu', (_ev, { x, y }) => {
Expand Down Expand Up @@ -273,15 +273,28 @@ export function openHtmlEmailWindow(
window.webContents.ipc.handle(
'html-view:resize-content',
(_ev, bounds: Electron.Rectangle) => {
const contentZoomFactor =
DesktopSettings.state.zoomFactor *
Math.pow(1.2, window.webContents.getZoomLevel())
const windowZoomFactor = window.webContents.getZoomFactor()

const window_bounds = window.getBounds()
const new_y = Math.floor(window_bounds.height - bounds.height)
const content_size = window.getContentSize()
const new_w = bounds.width * windowZoomFactor
const new_h = bounds.height * windowZoomFactor
const new_y = content_size[1] - new_h

sandboxedView?.setBounds({
...bounds,
x: bounds.x,
y: new_y,
width: new_w,
height: new_h,
})
sandboxedView?.webContents.setZoomFactor(contentZoomFactor)
DesktopSettings.update({ HTMLEmailWindowBounds: window_bounds })
}
)

window.on('moved', () => {
const window_bounds = window.getBounds()
DesktopSettings.update({ HTMLEmailWindowBounds: window_bounds })
Expand Down

0 comments on commit a6694b2

Please sign in to comment.