Skip to content

Commit

Permalink
Set traffic light height differently for Catalina (#160919)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 committed Sep 14, 2022
1 parent fc1ef74 commit b90f14f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/vs/workbench/electron-sandbox/parts/titlebar/titlebarPart.ts
Original file line number Diff line number Diff line change
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

0 comments on commit b90f14f

Please sign in to comment.