Skip to content

Commit 7c96708

Browse files
authored
fix title bar when transitioning to PWA (microsoft#165967)
fixes microsoft#165955
1 parent af497b4 commit 7c96708

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/vs/workbench/browser/layout.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
299299

300300
// Window focus changes
301301
this._register(this.hostService.onDidChangeFocus(e => this.onWindowFocusChanged(e)));
302+
303+
// WCO changes
304+
if (isWeb && typeof (navigator as any).windowControlsOverlay === 'object') {
305+
this._register(addDisposableListener((navigator as any).windowControlsOverlay, 'geometrychange', () => this.onDidChangeWCO()));
306+
}
302307
}
303308

304309
private onMenubarToggled(visible: boolean): void {
@@ -1104,6 +1109,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
11041109
}
11051110
}
11061111

1112+
private shouldShowBannerFirst(): boolean {
1113+
return isWeb && !isWCOVisible();
1114+
}
1115+
11071116
focus(): void {
11081117
this.focusPart(Parts.EDITOR_PART);
11091118
}
@@ -2008,6 +2017,17 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
20082017
return undefined;
20092018
}
20102019

2020+
private onDidChangeWCO(): void {
2021+
const bannerFirst = this.workbenchGrid.getNeighborViews(this.titleBarPartView, Direction.Up, false).length > 0;
2022+
const shouldBannerBeFirst = this.shouldShowBannerFirst();
2023+
2024+
if (bannerFirst !== shouldBannerBeFirst) {
2025+
this.workbenchGrid.moveView(this.bannerPartView, Sizing.Distribute, this.titleBarPartView, shouldBannerBeFirst ? Direction.Up : Direction.Down);
2026+
}
2027+
2028+
this.workbenchGrid.setViewVisible(this.titleBarPartView, this.shouldShowTitleBar());
2029+
}
2030+
20112031
private arrangeEditorNodes(nodes: { editor: ISerializedNode; sideBar?: ISerializedNode; auxiliaryBar?: ISerializedNode }, availableHeight: number, availableWidth: number): ISerializedNode {
20122032
if (!nodes.sideBar && !nodes.auxiliaryBar) {
20132033
nodes.editor.size = availableHeight;
@@ -2187,7 +2207,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
21872207
type: 'branch',
21882208
size: width,
21892209
data: [
2190-
...(isWeb ? titleAndBanner.reverse() : titleAndBanner),
2210+
...(this.shouldShowBannerFirst() ? titleAndBanner.reverse() : titleAndBanner),
21912211
{
21922212
type: 'branch',
21932213
data: middleSection,

0 commit comments

Comments
 (0)