解决标题栏中没有最小化、最大化、关闭等按钮.

This commit is contained in:
wangpenglong 2023-10-16 16:20:15 +08:00 committed by chriswang521
parent abcce6b843
commit 0fd9b24158
2 changed files with 9 additions and 4 deletions

View File

@ -205,3 +205,10 @@ if (window.matchMedia) {
export function isStandalone(): boolean { export function isStandalone(): boolean {
return standalone; 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;
}

View File

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * 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 { $, addDisposableListener, append, EventType, hide, prepend, show } from 'vs/base/browser/dom';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; 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 // Draggable region that we can manipulate for #52522
this.dragRegion = prepend(this.rootContainer, $('div.titlebar-drag-region')); this.dragRegion = prepend(this.rootContainer, $('div.titlebar-drag-region'));
// Window Controls (Native Windows/Linux) // Window Controls (Native Windows/Linux)
const hasWindowControlsOverlay = typeof (navigator as any).windowControlsOverlay !== 'undefined'; if (!isMacintosh && getTitleBarStyle(this.configurationService) !== 'native' && !isWCOEnabled() && this.windowControls) {
if (!isMacintosh && getTitleBarStyle(this.configurationService) !== 'native' && !hasWindowControlsOverlay && this.windowControls) {
// Minimize // Minimize
const minimizeIcon = append(this.windowControls, $('div.window-icon.window-minimize' + Codicon.chromeMinimize.cssSelector)); const minimizeIcon = append(this.windowControls, $('div.window-icon.window-minimize' + Codicon.chromeMinimize.cssSelector));
this._register(addDisposableListener(minimizeIcon, EventType.CLICK, e => { this._register(addDisposableListener(minimizeIcon, EventType.CLICK, e => {