From cb9a2fe8974b4dd998eff5544854576671b99021 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 9 Sep 2025 14:20:29 +1200 Subject: [PATCH] Added proper full screen support --- .gitignore | 4 ++++ main.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/.gitignore b/.gitignore index 50ba5b2..19ff0e4 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,7 @@ typings/ .idea/ site-history.json +bookmarks.json +bookmarks.backup.json +bookmarks.json +bookmarks.backup.json diff --git a/main.js b/main.js index e3072f4..d8e6567 100644 --- a/main.js +++ b/main.js @@ -805,6 +805,39 @@ app.on('web-contents-created', (event, contents) => { contents.on('context-menu', (e, params) => { buildAndShowContextMenu(contents, params); }); + + // On macOS, when a page (or a ) enters HTML fullscreen (e.g., YouTube video), + // also toggle the BrowserWindow into simple fullscreen so the content uses the whole + // screen and macOS traffic lights/titlebar are hidden. Revert when HTML fullscreen exits. + if (process.platform === 'darwin') { + const getOwningWindow = () => { + try { + const host = contents.hostWebContents || contents; + return BrowserWindow.fromWebContents(host) || null; + } catch { return null; } + }; + + contents.on('enter-html-full-screen', () => { + const win = getOwningWindow(); + if (!win) return; + win.__htmlFsDepth = (win.__htmlFsDepth || 0) + 1; + // If the window is already in native fullscreen (green button), don't switch modes + const alreadyNativeFs = typeof win.isFullScreen === 'function' && win.isFullScreen(); + if (!alreadyNativeFs && !win.isSimpleFullScreen?.()) { + try { win.setSimpleFullScreen?.(true); win.__htmlFsUsingSimple = true; } catch {} + } + }); + + contents.on('leave-html-full-screen', () => { + const win = getOwningWindow(); + if (!win) return; + win.__htmlFsDepth = Math.max(0, (win.__htmlFsDepth || 1) - 1); + if (win.__htmlFsDepth === 0 && win.__htmlFsUsingSimple) { + try { if (win.isSimpleFullScreen?.()) win.setSimpleFullScreen?.(false); } catch {} + win.__htmlFsUsingSimple = false; + } + }); + } }); // --- Image save handlers ---