aux window - some polish (#197510)

- seed the aux window ID based on the main one
- avoid using non-main windows for `getActiveWindowId`
This commit is contained in:
Benjamin Pasero 2023-11-06 08:22:33 +01:00 committed by GitHub
parent 14678c041f
commit 6454416d29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -33,7 +33,7 @@ export const { registerWindow, getWindows, getWindowsCount, getWindowId, onDidRe
const mainWindow = window as CodeWindow;
if (typeof mainWindow.vscodeWindowId !== 'number') {
Object.defineProperty(window, 'vscodeWindowId', {
get: () => -1
get: () => 1
});
}
windows.set(mainWindow.vscodeWindowId, { window: mainWindow, disposables: new DisposableStore() });

View file

@ -150,7 +150,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
}
async getActiveWindowId(windowId: number | undefined): Promise<number | undefined> {
const activeWindow = BrowserWindow.getFocusedWindow() || this.windowsMainService.getLastActiveWindow();
const activeWindow = this.windowsMainService.getFocusedWindow() || this.windowsMainService.getLastActiveWindow();
if (activeWindow) {
return activeWindow.id;
}

View file

@ -6,7 +6,7 @@
import { localize } from 'vs/nls';
import { mark } from 'vs/base/common/performance';
import { Emitter, Event } from 'vs/base/common/event';
import { CodeWindow, Dimension, EventHelper, EventType, addDisposableListener, cloneGlobalStylesheets, copyAttributes, createMetaElement, getActiveWindow, getClientArea, isGlobalStylesheet, position, registerWindow, sharedMutationObserver, size, trackAttributes } from 'vs/base/browser/dom';
import { CodeWindow, Dimension, EventHelper, EventType, addDisposableListener, cloneGlobalStylesheets, copyAttributes, createMetaElement, getActiveWindow, getClientArea, getWindowId, isGlobalStylesheet, position, registerWindow, sharedMutationObserver, size, trackAttributes } from 'vs/base/browser/dom';
import { Disposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
@ -62,7 +62,7 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili
private static readonly DEFAULT_SIZE = { width: 800, height: 600 };
private static WINDOW_IDS = 0;
private static WINDOW_IDS = getWindowId(window) + 1; // start from the main window ID + 1
private readonly _onDidOpenAuxiliaryWindow = this._register(new Emitter<IAuxiliaryWindowOpenEvent>());
readonly onDidOpenAuxiliaryWindow = this._onDidOpenAuxiliaryWindow.event;