diff --git a/src/main/index.js b/src/main/index.js index 90da8cbdfd083..9f3021a6f3eaa 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -596,6 +596,8 @@ function runApp() { } } + const htmlFullscreenWindowIds = new Set() + async function createWindow( { replaceMainWindow = true, @@ -768,7 +770,18 @@ function runApp() { } }) + newWindow.on('enter-html-full-screen', () => { + htmlFullscreenWindowIds.add(newWindow.id) + }) + + newWindow.on('leave-html-full-screen', () => { + htmlFullscreenWindowIds.delete(newWindow.id) + }) + newWindow.once('close', async () => { + // returns true if the element existed in the set + const htmlFullscreen = htmlFullscreenWindowIds.delete(newWindow.id) + if (BrowserWindow.getAllWindows().length !== 1) { return } @@ -776,7 +789,9 @@ function runApp() { const value = { ...newWindow.getNormalBounds(), maximized: newWindow.isMaximized(), - fullScreen: newWindow.isFullScreen() + + // Don't save the full screen state if it was triggered by an HTML API e.g. the video player + fullScreen: newWindow.isFullScreen() && !htmlFullscreen } await baseHandlers.settings._updateBounds(value)