Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set traffic light height differently for Catalina #160919

Merged
merged 1 commit into from Sep 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/vs/workbench/electron-sandbox/parts/titlebar/titlebarPart.ts
Expand Up @@ -30,9 +30,13 @@ export class TitlebarPart extends BrowserTitleBarPart {
private cachedWindowControlStyles: { bgColor: string; fgColor: string } | undefined;
private cachedWindowControlHeight: number | undefined;

private getMacTitlebarSize() {
private isBigSurOrNewer(): boolean {
const osVersion = this.environmentService.os.release;
if (parseFloat(osVersion) >= 20) { // Big Sur increases title bar height
return parseFloat(osVersion) >= 20;
}

private getMacTitlebarSize() {
if (this.isBigSurOrNewer()) { // Big Sur increases title bar height
return 28;
}

Expand Down Expand Up @@ -232,7 +236,12 @@ export class TitlebarPart extends BrowserTitleBarPart {

if (useWindowControlsOverlay(this.configurationService, this.environmentService) ||
(isMacintosh && isNative && getTitleBarStyle(this.configurationService) === 'custom')) {
const newHeight = Math.round(height * getZoomFactor());
// When the user goes into full screen mode, the height of the title bar becomes 0.
// Instead, set it back to the default titlebar height for Catalina users
// so that they can have the traffic lights rendered at the proper offset.
// Ref https://github.com/microsoft/vscode/issues/159862
const newHeight = (height > 0 || this.isBigSurOrNewer()) ?
Math.round(height * getZoomFactor()) : this.getMacTitlebarSize();
if (newHeight !== this.cachedWindowControlHeight) {
this.cachedWindowControlHeight = newHeight;
this.nativeHostService.updateWindowControls({ height: newHeight });
Expand Down