mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-04 20:36:01 +01:00
window - always set button height to prevent flicker (#211607)
* window - always set button height to prevent flicker * .
This commit is contained in:
@@ -221,6 +221,8 @@ export function getTitleBarStyle(configurationService: IConfigurationService): T
|
||||
return isLinux ? TitlebarStyle.NATIVE : TitlebarStyle.CUSTOM; // default to custom on all macOS and Windows
|
||||
}
|
||||
|
||||
export const DEFAULT_CUSTOM_TITLEBAR_HEIGHT = 35; // includes space for command center
|
||||
|
||||
export function useWindowControlsOverlay(configurationService: IConfigurationService): boolean {
|
||||
if (!isWindows || isWeb) {
|
||||
return false; // only supported on a desktop Windows instance
|
||||
|
||||
@@ -32,7 +32,7 @@ import { IApplicationStorageMainService, IStorageMainService } from 'vs/platform
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService';
|
||||
import { getMenuBarVisibility, IFolderToOpen, INativeWindowConfiguration, IWindowSettings, IWorkspaceToOpen, MenuBarVisibility, hasNativeTitlebar, useNativeFullScreen, useWindowControlsOverlay } from 'vs/platform/window/common/window';
|
||||
import { getMenuBarVisibility, IFolderToOpen, INativeWindowConfiguration, IWindowSettings, IWorkspaceToOpen, MenuBarVisibility, hasNativeTitlebar, useNativeFullScreen, useWindowControlsOverlay, DEFAULT_CUSTOM_TITLEBAR_HEIGHT } from 'vs/platform/window/common/window';
|
||||
import { defaultBrowserWindowOptions, IWindowsMainService, OpenContext, WindowStateValidator } from 'vs/platform/windows/electron-main/windows';
|
||||
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier, toWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
|
||||
import { IWorkspacesManagementMainService } from 'vs/platform/workspaces/electron-main/workspacesManagementMainService';
|
||||
@@ -136,11 +136,13 @@ export abstract class BaseWindow extends Disposable implements IBaseWindow {
|
||||
win.setSheetOffset(isBigSurOrNewer(release()) ? 28 : 22); // offset dialogs by the height of the custom title bar if we have any
|
||||
}
|
||||
|
||||
// Update the window controls immediately based on cached values
|
||||
// Update the window controls immediately based on cached or default values
|
||||
if (useCustomTitleStyle && ((isWindows && useWindowControlsOverlay(this.configurationService)) || isMacintosh)) {
|
||||
const cachedWindowControlHeight = this.stateService.getItem<number>((BaseWindow.windowControlHeightStateStorageKey));
|
||||
if (cachedWindowControlHeight) {
|
||||
this.updateWindowControls({ height: cachedWindowControlHeight });
|
||||
} else {
|
||||
this.updateWindowControls({ height: DEFAULT_CUSTOM_TITLEBAR_HEIGHT });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { localize, localize2 } from 'vs/nls';
|
||||
import { MultiWindowParts, Part } from 'vs/workbench/browser/part';
|
||||
import { ITitleService } from 'vs/workbench/services/title/browser/titleService';
|
||||
import { getZoomFactor, isWCOEnabled } from 'vs/base/browser/browser';
|
||||
import { MenuBarVisibility, getTitleBarStyle, getMenuBarVisibility, TitlebarStyle, hasCustomTitlebar, hasNativeTitlebar } from 'vs/platform/window/common/window';
|
||||
import { MenuBarVisibility, getTitleBarStyle, getMenuBarVisibility, TitlebarStyle, hasCustomTitlebar, hasNativeTitlebar, DEFAULT_CUSTOM_TITLEBAR_HEIGHT } from 'vs/platform/window/common/window';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -200,7 +200,7 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {
|
||||
readonly maximumWidth: number = Number.POSITIVE_INFINITY;
|
||||
|
||||
get minimumHeight(): number {
|
||||
const value = this.isCommandCenterVisible || (isWeb && isWCOEnabled()) ? 35 : 30;
|
||||
const value = this.isCommandCenterVisible || (isWeb && isWCOEnabled()) ? DEFAULT_CUSTOM_TITLEBAR_HEIGHT : 30;
|
||||
|
||||
return value / (this.preventZoom ? getZoomFactor(getWindow(this.element)) : 1);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { INativeHostService } from 'vs/platform/native/common/native';
|
||||
import { hasNativeTitlebar, useWindowControlsOverlay } from 'vs/platform/window/common/window';
|
||||
import { hasNativeTitlebar, useWindowControlsOverlay, DEFAULT_CUSTOM_TITLEBAR_HEIGHT } from 'vs/platform/window/common/window';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Codicon } from 'vs/base/common/codicons';
|
||||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
@@ -37,7 +37,7 @@ export class NativeTitlebarPart extends BrowserTitlebarPart {
|
||||
return super.minimumHeight;
|
||||
}
|
||||
|
||||
return (this.isCommandCenterVisible ? 35 : this.macTitlebarSize) / (this.preventZoom ? getZoomFactor(getWindow(this.element)) : 1);
|
||||
return (this.isCommandCenterVisible ? DEFAULT_CUSTOM_TITLEBAR_HEIGHT : this.macTitlebarSize) / (this.preventZoom ? getZoomFactor(getWindow(this.element)) : 1);
|
||||
}
|
||||
override get maximumHeight(): number { return this.minimumHeight; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user