Skip to content

Commit

Permalink
aux window - 💄
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Oct 30, 2023
1 parent ec89c51 commit 64b0376
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
7 changes: 4 additions & 3 deletions src/vs/base/browser/dom.ts
Expand Up @@ -791,8 +791,6 @@ export function focusWindow(element: Node): void {
}
}

const globalStylesheets = new Map<HTMLStyleElement /* main stylesheet */, Set<HTMLStyleElement /* aux window clones that track the main stylesheet */>>();

export function createStyleSheet(container: HTMLElement = document.head, beforeAppend?: (style: HTMLStyleElement) => void, disposableStore?: DisposableStore): HTMLStyleElement {
const style = document.createElement('style');
style.type = 'text/css';
Expand Down Expand Up @@ -827,6 +825,8 @@ export function createStyleSheet(container: HTMLElement = document.head, beforeA
return style;
}

const globalStylesheets = new Map<HTMLStyleElement /* main stylesheet */, Set<HTMLStyleElement /* aux window clones that track the main stylesheet */>>();

export function isGlobalStylesheet(node: Node): boolean {
return globalStylesheets.has(node as HTMLStyleElement);
}
Expand Down Expand Up @@ -905,14 +905,15 @@ export const sharedMutationObserver = new class {
observer.disconnect();

mutationObserversPerTarget?.delete(optionsHash);

if (mutationObserversPerTarget?.size === 0) {
this.mutationObservers.delete(target);
}
}
}));

mutationObserversPerTarget.set(optionsHash, mutationObserverPerOptions);
} else {
mutationObserverPerOptions.users += 1;
}

return mutationObserverPerOptions.onDidMutate;
Expand Down
12 changes: 6 additions & 6 deletions src/vs/platform/menubar/electron-main/menubar.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -92,7 +92,7 @@ export class Menubar {
this.addFallbackHandlers();

this.closedLastWindow = false;
this.noActiveWindow = false;
this.noActiveMainWindow = false;

this.oldMenus = [];

Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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:
Expand All @@ -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] })));
Expand Down
12 changes: 6 additions & 6 deletions src/vs/platform/window/common/window.ts
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/editor/editorPart.ts
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/electron-sandbox/window.ts
Expand Up @@ -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)));
}
}));
}
Expand Down

0 comments on commit 64b0376

Please sign in to comment.