Skip to content

Commit

Permalink
fix: after webview fullscreen force repaint
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Aug 5, 2024
1 parent bc7914f commit 4187b52
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,22 @@ export function createWindow(
...configs,
})

window.on("enter-html-full-screen", () => {
window.setBackgroundColor("")
window.webContents.invalidate()
})
window.on("leave-html-full-screen", () => {
window.setBackgroundColor("")

window.webContents.invalidate()
function refreshBound(timeout = 0) {
setTimeout(() => {
window.setBackgroundColor("#00000000")
}, 10_000)
const mainWindow = getMainWindow()
if (!mainWindow) return
// FIXME: workaround for theme bug in full screen mode
const size = mainWindow.getSize()
mainWindow.setSize(size[0] + 1, size[1] + 1)
mainWindow.setSize(size[0], size[1])
}, timeout)
}

window.on("leave-html-full-screen", () => {
// To solve the vibrancy losing issue when leaving full screen mode
// @see https://github.com/toeverything/AFFiNE/blob/280e24934a27557529479a70ab38c4f5fc65cb00/packages/frontend/electron/src/main/windows-manager/main-window.ts:L157
refreshBound()
refreshBound(1000)
})

window.on("ready-to-show", () => {
Expand Down

0 comments on commit 4187b52

Please sign in to comment.