Skip to content

Commit d9bc6b0

Browse files
authored
aux window - adjust to a full flex layout (microsoft#203669)
1 parent 16f38b9 commit d9bc6b0

File tree

2 files changed

+25
-28
lines changed

2 files changed

+25
-28
lines changed

src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.ts

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { isFullscreen, onDidChangeFullscreen, onDidChangeZoomLevel } from 'vs/base/browser/browser';
6+
import { isFullscreen, onDidChangeFullscreen } from 'vs/base/browser/browser';
77
import { hide, show } from 'vs/base/browser/dom';
88
import { Emitter, Event } from 'vs/base/common/event';
99
import { DisposableStore } from 'vs/base/common/lifecycle';
@@ -77,12 +77,6 @@ export class AuxiliaryEditorPart {
7777
hide(statusbarPart.container);
7878
}
7979

80-
updateEditorPartHeight(fromEvent);
81-
}
82-
83-
function updateEditorPartHeight(fromEvent: boolean): void {
84-
editorPartContainer.style.height = `calc(100% - ${computeEditorPartHeightOffset()}px)`;
85-
8680
if (fromEvent) {
8781
auxiliaryWindow.layout();
8882
}
@@ -112,20 +106,7 @@ export class AuxiliaryEditorPart {
112106
titlebarPart = disposables.add(this.titleService.createAuxiliaryTitlebarPart(auxiliaryWindow.container, editorPart));
113107
titlebarPartVisible = true;
114108

115-
disposables.add(titlebarPart.onDidChange(() => updateEditorPartHeight(true)));
116-
disposables.add(onDidChangeZoomLevel(targetWindowId => {
117-
if (auxiliaryWindow.window.vscodeWindowId === targetWindowId && titlebarPartVisible) {
118-
119-
// This is a workaround for https://github.com/microsoft/vscode/issues/202377
120-
// The title bar part prevents zooming in certain cases and when doing so,
121-
// adjusts its size accordingly. This is however not reported from the
122-
// `onDidchange` event that we listen to above, so we manually update the
123-
// editor part height here.
124-
125-
updateEditorPartHeight(true);
126-
}
127-
}));
128-
109+
disposables.add(titlebarPart.onDidChange(() => auxiliaryWindow.layout()));
129110
disposables.add(onDidChangeFullscreen(windowId => {
130111
if (windowId !== auxiliaryWindow.window.vscodeWindowId) {
131112
return; // ignore all but our window
@@ -140,7 +121,7 @@ export class AuxiliaryEditorPart {
140121
if (titlebarPart && oldTitlebarPartVisible !== titlebarPartVisible) {
141122
titlebarPart.container.style.display = titlebarPartVisible ? '' : 'none';
142123

143-
updateEditorPartHeight(true);
124+
auxiliaryWindow.layout();
144125
}
145126
}));
146127
} else {
@@ -173,8 +154,10 @@ export class AuxiliaryEditorPart {
173154
}));
174155
disposables.add(Event.once(this.lifecycleService.onDidShutdown)(() => disposables.dispose()));
175156

176-
// Layout
177-
disposables.add(auxiliaryWindow.onDidLayout(dimension => {
157+
// Layout: specifically `onWillLayout` to have a chance
158+
// to build the aux editor part before other components
159+
// have a chance to react.
160+
disposables.add(auxiliaryWindow.onWillLayout(dimension => {
178161
const titlebarPartHeight = titlebarPart?.height ?? 0;
179162
titlebarPart?.layout(dimension.width, titlebarPartHeight, 0, 0);
180163

src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { localize } from 'vs/nls';
77
import { mark } from 'vs/base/common/performance';
88
import { Emitter, Event } from 'vs/base/common/event';
9-
import { Dimension, EventHelper, EventType, ModifierKeyEmitter, addDisposableListener, cloneGlobalStylesheets, copyAttributes, createLinkElement, createMetaElement, getActiveWindow, getClientArea, getWindowId, isGlobalStylesheet, position, registerWindow, sharedMutationObserver, size, trackAttributes } from 'vs/base/browser/dom';
9+
import { Dimension, EventHelper, EventType, ModifierKeyEmitter, addDisposableListener, cloneGlobalStylesheets, copyAttributes, createLinkElement, createMetaElement, getActiveWindow, getClientArea, getWindowId, isGlobalStylesheet, position, registerWindow, sharedMutationObserver, trackAttributes } from 'vs/base/browser/dom';
1010
import { CodeWindow, ensureCodeWindow, mainWindow } from 'vs/base/browser/window';
1111
import { Disposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
1212
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
@@ -46,6 +46,7 @@ export interface IAuxiliaryWindowService {
4646

4747
export interface IAuxiliaryWindow extends IDisposable {
4848

49+
readonly onWillLayout: Event<Dimension>;
4950
readonly onDidLayout: Event<Dimension>;
5051

5152
readonly onBeforeUnload: Event<void>;
@@ -61,6 +62,9 @@ export interface IAuxiliaryWindow extends IDisposable {
6162

6263
export class AuxiliaryWindow extends BaseWindow implements IAuxiliaryWindow {
6364

65+
private readonly _onWillLayout = this._register(new Emitter<Dimension>());
66+
readonly onWillLayout = this._onWillLayout.event;
67+
6468
private readonly _onDidLayout = this._register(new Emitter<Dimension>());
6569
readonly onDidLayout = this._onDidLayout.event;
6670

@@ -136,10 +140,16 @@ export class AuxiliaryWindow extends BaseWindow implements IAuxiliaryWindow {
136140
}
137141

138142
layout(): void {
139-
const dimension = getClientArea(this.window.document.body, this.container);
140-
position(this.container, 0, 0, 0, 0, 'relative');
141-
size(this.container, dimension.width, dimension.height);
142143

144+
// Split layout up into two events so that downstream components
145+
// have a chance to participate in the beginning or end of the
146+
// layout phase.
147+
// This helps to build the auxiliary window in another component
148+
// in the `onWillLayout` phase and then let other compoments
149+
// react when the overall layout has finished in `onDidLayout`.
150+
151+
const dimension = getClientArea(this.window.document.body, this.container);
152+
this._onWillLayout.fire(dimension);
143153
this._onDidLayout.fire(dimension);
144154
}
145155

@@ -418,6 +428,10 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili
418428
// Create workbench container and apply classes
419429
const container = document.createElement('div');
420430
container.setAttribute('role', 'application');
431+
position(container, 0, 0, 0, 0, 'relative');
432+
container.style.display = 'flex';
433+
container.style.height = '100%';
434+
container.style.flexDirection = 'column';
421435
auxiliaryWindow.document.body.append(container);
422436

423437
// Track attributes

0 commit comments

Comments
 (0)