From 0fd9b24158d9b5ce007a51a45e542ba6acfc78b0 Mon Sep 17 00:00:00 2001 From: wangpenglong Date: Mon, 16 Oct 2023 16:20:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=87=E9=A2=98=E6=A0=8F?= =?UTF-8?q?=E4=B8=AD=E6=B2=A1=E6=9C=89=E6=9C=80=E5=B0=8F=E5=8C=96=E3=80=81?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E5=8C=96=E3=80=81=E5=85=B3=E9=97=AD=E7=AD=89?= =?UTF-8?q?=E6=8C=89=E9=92=AE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/vs/base/browser/browser.ts | 7 +++++++ .../electron-sandbox/parts/titlebar/titlebarPart.ts | 6 ++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/vs/base/browser/browser.ts b/src/vs/base/browser/browser.ts index d41cafcd..cf70d65e 100644 --- a/src/vs/base/browser/browser.ts +++ b/src/vs/base/browser/browser.ts @@ -205,3 +205,10 @@ if (window.matchMedia) { export function isStandalone(): boolean { return standalone; } + +// Visible means that the feature is enabled, not necessarily being rendered +// e.g. visible is true even in fullscreen mode where the controls are hidden +// See docs at https://developer.mozilla.org/en-US/docs/Web/API/WindowControlsOverlay/visible +export function isWCOEnabled(): boolean { + return (navigator as any)?.windowControlsOverlay?.visible; +} diff --git a/src/vs/workbench/electron-sandbox/parts/titlebar/titlebarPart.ts b/src/vs/workbench/electron-sandbox/parts/titlebar/titlebarPart.ts index e4f9c4f5..227de2c0 100644 --- a/src/vs/workbench/electron-sandbox/parts/titlebar/titlebarPart.ts +++ b/src/vs/workbench/electron-sandbox/parts/titlebar/titlebarPart.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { getZoomFactor } from 'vs/base/browser/browser'; +import { getZoomFactor, isWCOEnabled } from 'vs/base/browser/browser'; import { $, addDisposableListener, append, EventType, hide, prepend, show } from 'vs/base/browser/dom'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; @@ -155,10 +155,8 @@ export class TitlebarPart extends BrowserTitleBarPart { // Draggable region that we can manipulate for #52522 this.dragRegion = prepend(this.rootContainer, $('div.titlebar-drag-region')); - // Window Controls (Native Windows/Linux) - const hasWindowControlsOverlay = typeof (navigator as any).windowControlsOverlay !== 'undefined'; - if (!isMacintosh && getTitleBarStyle(this.configurationService) !== 'native' && !hasWindowControlsOverlay && this.windowControls) { + if (!isMacintosh && getTitleBarStyle(this.configurationService) !== 'native' && !isWCOEnabled() && this.windowControls) { // Minimize const minimizeIcon = append(this.windowControls, $('div.window-icon.window-minimize' + Codicon.chromeMinimize.cssSelector)); this._register(addDisposableListener(minimizeIcon, EventType.CLICK, e => {