|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Gaspar Chefdeville <gaspar.chefdeville@coderpad.io> |
| 3 | +Date: Wed, 9 Jul 2025 17:07:58 +0200 |
| 4 | +Subject: [PATCH] fix: provide correct container and check if fullscreen |
| 5 | + |
| 6 | +--- |
| 7 | + src/vs/base/browser/dom.ts | 8 +++++--- |
| 8 | + .../workbench/services/host/browser/browserHostService.ts | 2 +- |
| 9 | + 2 files changed, 6 insertions(+), 4 deletions(-) |
| 10 | + |
| 11 | +diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts |
| 12 | +index 44afc1906a7..af89a7f1e46 100644 |
| 13 | +--- a/src/vs/base/browser/dom.ts |
| 14 | ++++ b/src/vs/base/browser/dom.ts |
| 15 | +@@ -1626,7 +1626,7 @@ export interface IDetectedFullscreen { |
| 16 | + guess: boolean; |
| 17 | + } |
| 18 | + |
| 19 | +-export function detectFullscreen(targetWindow: Window, containerElement?: Element): IDetectedFullscreen | null { |
| 20 | ++export function detectFullscreen(targetWindow: Window, containerElement: Element): IDetectedFullscreen | null { |
| 21 | + |
| 22 | + // Browser fullscreen: use DOM APIs to detect |
| 23 | + const fullscreenElement: Element | undefined = |
| 24 | +@@ -1640,7 +1640,9 @@ export function detectFullscreen(targetWindow: Window, containerElement?: Elemen |
| 25 | + // height and comparing that to window height, we can guess |
| 26 | + // it though. |
| 27 | + |
| 28 | +- if (targetWindow.innerHeight === targetWindow.screen.height) { |
| 29 | ++ const isContainerFullScreen = containerElement.getBoundingClientRect().height >= targetWindow.screen.height; |
| 30 | ++ |
| 31 | ++ if (targetWindow.innerHeight === targetWindow.screen.height && isContainerFullScreen) { |
| 32 | + // if the height of the window matches the screen height, we can |
| 33 | + // safely assume that the browser is fullscreen because no browser |
| 34 | + // chrome is taking height away (e.g. like toolbars). |
| 35 | +@@ -1649,7 +1651,7 @@ export function detectFullscreen(targetWindow: Window, containerElement?: Elemen |
| 36 | + |
| 37 | + if (platform.isMacintosh || platform.isLinux) { |
| 38 | + // macOS and Linux do not properly report `innerHeight`, only Windows does |
| 39 | +- if (targetWindow.outerHeight === targetWindow.screen.height && targetWindow.outerWidth === targetWindow.screen.width) { |
| 40 | ++ if (targetWindow.outerHeight === targetWindow.screen.height && targetWindow.outerWidth === targetWindow.screen.width && isContainerFullScreen) { |
| 41 | + // if the height of the browser matches the screen height, we can |
| 42 | + // only guess that we are in fullscreen. It is also possible that |
| 43 | + // the user has turned off taskbars in the OS and the browser is |
| 44 | +diff --git a/src/vs/workbench/services/host/browser/browserHostService.ts b/src/vs/workbench/services/host/browser/browserHostService.ts |
| 45 | +index 851a4cfad41..6e41a554052 100644 |
| 46 | +--- a/src/vs/workbench/services/host/browser/browserHostService.ts |
| 47 | ++++ b/src/vs/workbench/services/host/browser/browserHostService.ts |
| 48 | +@@ -218,7 +218,7 @@ export class BrowserHostService extends Disposable implements IHostService { |
| 49 | + const viewport = isIOS && window.visualViewport ? window.visualViewport /** Visual viewport */ : window /** Layout viewport */; |
| 50 | + |
| 51 | + const isFullScreen = () => { |
| 52 | +- const fullScreen = detectFullscreen(window, mainWindow.document.body); |
| 53 | ++ const fullScreen = detectFullscreen(window, this.layoutService.getContainer(window)); |
| 54 | + return fullScreen !== null && !fullScreen.guess; |
| 55 | + }; |
| 56 | + |
0 commit comments