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

aux window - add layout method #195221

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/vs/workbench/browser/parts/editor/editorParts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export class EditorParts extends Disposable implements IEditorGroupsService, IEd
disposables.add(Event.once(this.lifecycleService.onDidShutdown)(() => disposables.dispose()));

editorPart.create(partContainer, { restorePreviousState: false });
disposables.add(auxiliaryWindow.onDidResize(dimension => editorPart.layout(dimension.width, dimension.height, 0, 0)));

disposables.add(auxiliaryWindow.onWillLayout(dimension => editorPart.layout(dimension.width, dimension.height, 0, 0)));
auxiliaryWindow.layout();

this._onDidAddGroup.fire(editorPart.activeGroup);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ export interface IAuxiliaryWindowService {

export interface IAuxiliaryWindow extends IDisposable {

readonly onDidResize: Event<Dimension>;
readonly onWillLayout: Event<Dimension>;
readonly onDidClose: Event<void>;

readonly container: HTMLElement;

layout(): void;
}

type AuxiliaryWindow = Window & typeof globalThis;
Expand Down Expand Up @@ -56,12 +58,13 @@ export class BrowserAuxiliaryWindowService implements IAuxiliaryWindowService {

const container = this.applyHTML(auxiliaryWindow, disposables);

const { onDidResize, onDidClose } = this.registerListeners(auxiliaryWindow, container, disposables);
const { onWillLayout, onDidClose } = this.registerListeners(auxiliaryWindow, container, disposables);

return {
container,
onDidResize: onDidResize.event,
onWillLayout: onWillLayout.event,
onDidClose: onDidClose.event,
layout: () => onWillLayout.fire(getClientArea(container)),
dispose: () => disposables.dispose()
};
}
Expand Down Expand Up @@ -123,7 +126,7 @@ export class BrowserAuxiliaryWindowService implements IAuxiliaryWindowService {
return container;
}

private registerListeners(auxiliaryWindow: AuxiliaryWindow, container: HTMLElement, disposables: DisposableStore) {
private registerListeners(auxiliaryWindow: AuxiliaryWindow, container: HTMLElement, disposables: DisposableStore): { onWillLayout: Emitter<Dimension>; onDidClose: Emitter<void> } {
const onDidClose = disposables.add(new Emitter<void>());
disposables.add(addDisposableListener(auxiliaryWindow, 'unload', () => {
onDidClose.fire();
Expand All @@ -134,13 +137,13 @@ export class BrowserAuxiliaryWindowService implements IAuxiliaryWindowService {
e.preventDefault();
}));

const onDidResize = disposables.add(new Emitter<Dimension>());
const onWillLayout = disposables.add(new Emitter<Dimension>());
disposables.add(addDisposableListener(auxiliaryWindow, EventType.RESIZE, () => {
const dimension = getClientArea(auxiliaryWindow.document.body);
position(container, 0, 0, 0, 0, 'relative');
size(container, dimension.width, dimension.height);

onDidResize.fire(dimension);
onWillLayout.fire(dimension);
}));

if (isWeb) {
Expand All @@ -152,7 +155,7 @@ export class BrowserAuxiliaryWindowService implements IAuxiliaryWindowService {
disposables.add(addDisposableListener(auxiliaryWindow.document.body, EventType.DROP, (e: DragEvent) => EventHelper.stop(e))); // Prevent default navigation on drop
}

return { onDidResize, onDidClose };
return { onWillLayout, onDidClose };
}

protected patchMethods(auxiliaryWindow: AuxiliaryWindow): void {
Expand Down