From 201440371bf5ce221bdecda7378daae5f8b0d1ba Mon Sep 17 00:00:00 2001 From: drull Date: Thu, 26 Mar 2026 19:38:54 -0300 Subject: [PATCH 1/3] Make FT reopen in fullscreen after being closed with FS window and player --- src/main/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index 64e8d2e7525a9..2e0900366cf42 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -871,6 +871,7 @@ function runApp() { } const htmlFullscreenWindowIds = new Set() + const windowFullscreenBeforeHtmlFullscreen = new Map() async function createWindow( { @@ -1159,16 +1160,20 @@ function runApp() { } newWindow.on('enter-html-full-screen', () => { + windowFullscreenBeforeHtmlFullscreen.set(newWindow.id, newWindow.isFullScreen()) htmlFullscreenWindowIds.add(newWindow.id) }) newWindow.on('leave-html-full-screen', () => { htmlFullscreenWindowIds.delete(newWindow.id) + windowFullscreenBeforeHtmlFullscreen.delete(newWindow.id) }) newWindow.once('close', async () => { // returns true if the element existed in the set const htmlFullscreen = htmlFullscreenWindowIds.delete(newWindow.id) + const wasFullscreenBeforeHtml = windowFullscreenBeforeHtmlFullscreen.get(newWindow.id) ?? false + windowFullscreenBeforeHtmlFullscreen.delete(newWindow.id) if (BrowserWindow.getAllWindows().length !== 1) { return @@ -1179,7 +1184,8 @@ function runApp() { maximized: newWindow.isMaximized(), // Don't save the full screen state if it was triggered by an HTML API e.g. the video player - fullScreen: newWindow.isFullScreen() && !htmlFullscreen + // But do save it if the window was already in fullscreen before entering HTML fullscreen + fullScreen: newWindow.isFullScreen() && (!htmlFullscreen || wasFullscreenBeforeHtml) } await baseHandlers.settings._updateBounds(value) From 07bf860f5d0bed402606a814f7ebaf7afca4f8cb Mon Sep 17 00:00:00 2001 From: drull Date: Fri, 27 Mar 2026 08:51:48 -0300 Subject: [PATCH 2/3] Fix FT opening in FS just because the video was FS --- src/main/index.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 2e0900366cf42..5d014fafe1432 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -871,7 +871,7 @@ function runApp() { } const htmlFullscreenWindowIds = new Set() - const windowFullscreenBeforeHtmlFullscreen = new Map() + const nativeFullscreenWindowIds = new Set() async function createWindow( { @@ -1160,20 +1160,27 @@ function runApp() { } newWindow.on('enter-html-full-screen', () => { - windowFullscreenBeforeHtmlFullscreen.set(newWindow.id, newWindow.isFullScreen()) htmlFullscreenWindowIds.add(newWindow.id) }) newWindow.on('leave-html-full-screen', () => { htmlFullscreenWindowIds.delete(newWindow.id) - windowFullscreenBeforeHtmlFullscreen.delete(newWindow.id) + }) + + newWindow.on('enter-full-screen', () => { + // Only track as native fullscreen if not triggered by HTML fullscreen + if (!htmlFullscreenWindowIds.has(newWindow.id)) { + nativeFullscreenWindowIds.add(newWindow.id) + } + }) + + newWindow.on('leave-full-screen', () => { + nativeFullscreenWindowIds.delete(newWindow.id) }) newWindow.once('close', async () => { - // returns true if the element existed in the set - const htmlFullscreen = htmlFullscreenWindowIds.delete(newWindow.id) - const wasFullscreenBeforeHtml = windowFullscreenBeforeHtmlFullscreen.get(newWindow.id) ?? false - windowFullscreenBeforeHtmlFullscreen.delete(newWindow.id) + htmlFullscreenWindowIds.delete(newWindow.id) + const nativeFullscreen = nativeFullscreenWindowIds.delete(newWindow.id) if (BrowserWindow.getAllWindows().length !== 1) { return @@ -1183,9 +1190,8 @@ function runApp() { ...newWindow.getNormalBounds(), maximized: newWindow.isMaximized(), - // Don't save the full screen state if it was triggered by an HTML API e.g. the video player - // But do save it if the window was already in fullscreen before entering HTML fullscreen - fullScreen: newWindow.isFullScreen() && (!htmlFullscreen || wasFullscreenBeforeHtml) + // Only save fullscreen if it was triggered by native fullscreen (F11), not HTML API (video player) + fullScreen: nativeFullscreen } await baseHandlers.settings._updateBounds(value) From 3d5ea25634775243033581e278b291c593cf6e3c Mon Sep 17 00:00:00 2001 From: Caetano-dev Date: Mon, 30 Mar 2026 14:35:31 -0300 Subject: [PATCH 3/3] Fix fullscreen state detection race condition --- src/main/index.js | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 5d014fafe1432..9119f236cc756 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -872,6 +872,8 @@ function runApp() { const htmlFullscreenWindowIds = new Set() const nativeFullscreenWindowIds = new Set() + const nativeFullscreenBeforeHtmlFullscreen = new Map() + const recentFullscreenEvents = new Map() // Track recent enter-full-screen events async function createWindow( { @@ -1161,13 +1163,34 @@ function runApp() { newWindow.on('enter-html-full-screen', () => { htmlFullscreenWindowIds.add(newWindow.id) + + // Check if enter-full-screen fired recently (within 100ms) - indicates race condition + const recentEvent = recentFullscreenEvents.get(newWindow.id) + const now = Date.now() + + if (recentEvent && (now - recentEvent) < 100) { + // enter-full-screen fired just before this event - it was triggered by HTML fullscreen + // So the window was NOT in native fullscreen before + nativeFullscreenBeforeHtmlFullscreen.set(newWindow.id, false) + nativeFullscreenWindowIds.delete(newWindow.id) // Remove the incorrectly added entry + } else { + // enter-full-screen did not fire recently, so check current state + nativeFullscreenBeforeHtmlFullscreen.set(newWindow.id, nativeFullscreenWindowIds.has(newWindow.id)) + } + + recentFullscreenEvents.delete(newWindow.id) }) newWindow.on('leave-html-full-screen', () => { htmlFullscreenWindowIds.delete(newWindow.id) + nativeFullscreenBeforeHtmlFullscreen.delete(newWindow.id) + recentFullscreenEvents.delete(newWindow.id) }) newWindow.on('enter-full-screen', () => { + // Track when this event fired + recentFullscreenEvents.set(newWindow.id, Date.now()) + // Only track as native fullscreen if not triggered by HTML fullscreen if (!htmlFullscreenWindowIds.has(newWindow.id)) { nativeFullscreenWindowIds.add(newWindow.id) @@ -1175,12 +1198,19 @@ function runApp() { }) newWindow.on('leave-full-screen', () => { - nativeFullscreenWindowIds.delete(newWindow.id) + // Only remove from native fullscreen tracking if not in HTML fullscreen + // or if we're leaving both native and HTML fullscreen together + if (!htmlFullscreenWindowIds.has(newWindow.id)) { + nativeFullscreenWindowIds.delete(newWindow.id) + } }) newWindow.once('close', async () => { - htmlFullscreenWindowIds.delete(newWindow.id) - const nativeFullscreen = nativeFullscreenWindowIds.delete(newWindow.id) + const wasHtmlFullscreen = htmlFullscreenWindowIds.delete(newWindow.id) + const wasNativeFullscreen = nativeFullscreenWindowIds.delete(newWindow.id) + const wasNativeBeforeHtml = nativeFullscreenBeforeHtmlFullscreen.get(newWindow.id) ?? false + nativeFullscreenBeforeHtmlFullscreen.delete(newWindow.id) + recentFullscreenEvents.delete(newWindow.id) if (BrowserWindow.getAllWindows().length !== 1) { return @@ -1191,7 +1221,8 @@ function runApp() { maximized: newWindow.isMaximized(), // Only save fullscreen if it was triggered by native fullscreen (F11), not HTML API (video player) - fullScreen: nativeFullscreen + // If HTML fullscreen is active at close, only save fullscreen if window was already fullscreen before video + fullScreen: wasNativeFullscreen && (!wasHtmlFullscreen || wasNativeBeforeHtml) } await baseHandlers.settings._updateBounds(value)