From 64b037670a6f2323b0c93504dd1a2d5e6c0c7d95 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 30 Oct 2023 07:54:51 +0100 Subject: [PATCH] aux window - :lipstick: --- src/vs/base/browser/dom.ts | 7 ++++--- src/vs/platform/menubar/electron-main/menubar.ts | 12 ++++++------ src/vs/platform/window/common/window.ts | 12 ++++++------ src/vs/workbench/browser/parts/editor/editorPart.ts | 4 ++-- src/vs/workbench/electron-sandbox/window.ts | 3 ++- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index c398b0afc51cf..13ff65cfb4eb6 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -791,8 +791,6 @@ export function focusWindow(element: Node): void { } } -const globalStylesheets = new Map>(); - export function createStyleSheet(container: HTMLElement = document.head, beforeAppend?: (style: HTMLStyleElement) => void, disposableStore?: DisposableStore): HTMLStyleElement { const style = document.createElement('style'); style.type = 'text/css'; @@ -827,6 +825,8 @@ export function createStyleSheet(container: HTMLElement = document.head, beforeA return style; } +const globalStylesheets = new Map>(); + export function isGlobalStylesheet(node: Node): boolean { return globalStylesheets.has(node as HTMLStyleElement); } @@ -905,7 +905,6 @@ export const sharedMutationObserver = new class { observer.disconnect(); mutationObserversPerTarget?.delete(optionsHash); - if (mutationObserversPerTarget?.size === 0) { this.mutationObservers.delete(target); } @@ -913,6 +912,8 @@ export const sharedMutationObserver = new class { })); mutationObserversPerTarget.set(optionsHash, mutationObserverPerOptions); + } else { + mutationObserverPerOptions.users += 1; } return mutationObserverPerOptions.onDidMutate; diff --git a/src/vs/platform/menubar/electron-main/menubar.ts b/src/vs/platform/menubar/electron-main/menubar.ts index 78eb3f1e00a37..ed5141b1d0a3e 100644 --- a/src/vs/platform/menubar/electron-main/menubar.ts +++ b/src/vs/platform/menubar/electron-main/menubar.ts @@ -49,7 +49,7 @@ export class Menubar { private willShutdown: boolean | undefined; private appMenuInstalled: boolean | undefined; private closedLastWindow: boolean; - private noActiveWindow: boolean; + private noActiveMainWindow: boolean; private menuUpdater: RunOnceScheduler; private menuGC: RunOnceScheduler; @@ -92,7 +92,7 @@ export class Menubar { this.addFallbackHandlers(); this.closedLastWindow = false; - this.noActiveWindow = false; + this.noActiveMainWindow = false; this.oldMenus = []; @@ -247,7 +247,7 @@ export class Menubar { } const focusedWindow = BrowserWindow.getFocusedWindow(); - this.noActiveWindow = !focusedWindow || !!this.auxiliaryWindowsMainService.getWindowById(focusedWindow.id); + this.noActiveMainWindow = !focusedWindow || !!this.auxiliaryWindowsMainService.getWindowById(focusedWindow.id); this.scheduleUpdateMenu(); } @@ -477,12 +477,12 @@ export class Menubar { case 'File': case 'Help': if (isMacintosh) { - return (this.windowsMainService.getWindowCount() === 0 && this.closedLastWindow) || (this.windowsMainService.getWindowCount() > 0 && this.noActiveWindow) || (!!this.menubarMenus && !!this.menubarMenus[menuId]); + return (this.windowsMainService.getWindowCount() === 0 && this.closedLastWindow) || (this.windowsMainService.getWindowCount() > 0 && this.noActiveMainWindow) || (!!this.menubarMenus && !!this.menubarMenus[menuId]); } case 'Window': if (isMacintosh) { - return (this.windowsMainService.getWindowCount() === 0 && this.closedLastWindow) || (this.windowsMainService.getWindowCount() > 0 && this.noActiveWindow) || !!this.menubarMenus; + return (this.windowsMainService.getWindowCount() === 0 && this.closedLastWindow) || (this.windowsMainService.getWindowCount() > 0 && this.noActiveMainWindow) || !!this.menubarMenus; } default: @@ -509,7 +509,7 @@ export class Menubar { if (isMacintosh) { if ((this.windowsMainService.getWindowCount() === 0 && this.closedLastWindow) || - (this.windowsMainService.getWindowCount() > 0 && this.noActiveWindow)) { + (this.windowsMainService.getWindowCount() > 0 && this.noActiveMainWindow)) { // In the fallback scenario, we are either disabled or using a fallback handler if (this.fallbackMenuHandlers[item.id]) { menu.append(new MenuItem(this.likeAction(item.id, { label: this.mnemonicLabel(item.label), click: this.fallbackMenuHandlers[item.id] }))); diff --git a/src/vs/platform/window/common/window.ts b/src/vs/platform/window/common/window.ts index 5648bec827903..442c421ef5ef3 100644 --- a/src/vs/platform/window/common/window.ts +++ b/src/vs/platform/window/common/window.ts @@ -70,19 +70,19 @@ export interface IAddFoldersRequest { readonly foldersToAdd: UriComponents[]; } -export interface IOpenedMainWindow { +interface IOpenedWindow { readonly id: number; - readonly workspace?: IAnyWorkspaceIdentifier; readonly title: string; readonly filename?: string; +} + +export interface IOpenedMainWindow extends IOpenedWindow { + readonly workspace?: IAnyWorkspaceIdentifier; readonly dirty: boolean; } -export interface IOpenedAuxiliaryWindow { - readonly id: number; +export interface IOpenedAuxiliaryWindow extends IOpenedWindow { readonly parentId: number; - readonly title: string; - readonly filename?: string; } export function isOpenedAuxiliaryWindow(candidate: IOpenedMainWindow | IOpenedAuxiliaryWindow): candidate is IOpenedAuxiliaryWindow { diff --git a/src/vs/workbench/browser/parts/editor/editorPart.ts b/src/vs/workbench/browser/parts/editor/editorPart.ts index bc3c683d128b4..57e9e784a1b7f 100644 --- a/src/vs/workbench/browser/parts/editor/editorPart.ts +++ b/src/vs/workbench/browser/parts/editor/editorPart.ts @@ -756,10 +756,10 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupsView { } // Remove group with editors - this.doRemoveGroupWithEditors(groupView, preserveFocus); + this.doRemoveGroupWithEditors(groupView); } - private doRemoveGroupWithEditors(groupView: IEditorGroupView, preserveFocus?: boolean): void { + private doRemoveGroupWithEditors(groupView: IEditorGroupView): void { const mostRecentlyActiveGroups = this.getGroups(GroupsOrder.MOST_RECENTLY_ACTIVE); let lastActiveGroup: IEditorGroupView; diff --git a/src/vs/workbench/electron-sandbox/window.ts b/src/vs/workbench/electron-sandbox/window.ts index 93f2c0e3c840f..bddfc483eb496 100644 --- a/src/vs/workbench/electron-sandbox/window.ts +++ b/src/vs/workbench/electron-sandbox/window.ts @@ -367,7 +367,8 @@ export class NativeWindow extends Disposable { this._register(this.auxiliaryWindowService.onDidOpenAuxiliaryWindow(({ window, disposables }) => { const auxiliaryWindowEditorPart = this.editorGroupService.getPart(window.container); if (auxiliaryWindowEditorPart) { - disposables.add(this.editorService.createScoped(auxiliaryWindowEditorPart, disposables).onDidActiveEditorChange(() => updateRepresentedFilename(this.mainPartEditorService, window.window.vscodeWindowId))); + const auxiliaryEditorService = this.editorService.createScoped(auxiliaryWindowEditorPart, disposables); + disposables.add(auxiliaryEditorService.onDidActiveEditorChange(() => updateRepresentedFilename(auxiliaryEditorService, window.window.vscodeWindowId))); } })); }