From c2a4e7f50d22391d36254a466f7e74a4b51a3878 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Mon, 20 May 2024 22:46:01 +0200 Subject: [PATCH] Fix player full screen causing the app to start in full screen --- src/main/index.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index dd2a65667a916..ba8dd5c4c4af1 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -602,6 +602,8 @@ function runApp() { } } + const htmlFullscreenWindowIds = new Set() + async function createWindow( { replaceMainWindow = true, @@ -774,7 +776,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 } @@ -782,7 +795,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)