Skip to content

Commit 722dd9a

Browse files
author
Benjamin Pasero
committed
Revert "Revert - remove getActiveWindowId change"
This reverts commit 4a44dd5.
1 parent cd90f80 commit 722dd9a

7 files changed

Lines changed: 9 additions & 28 deletions

File tree

src/vs/platform/windows/common/windows.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export interface IWindowsService {
4242
clearRecentlyOpened(): Promise<void>;
4343
getRecentlyOpened(windowId: number): Promise<IRecentlyOpened>;
4444
isFocused(windowId: number): Promise<boolean>;
45-
getActiveWindowId(): Promise<number | undefined>;
4645
}
4746

4847
export const IWindowService = createDecorator<IWindowService>('windowService');

src/vs/platform/windows/common/windowsIpc.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export class WindowsChannel implements IServerChannel {
5858
case 'getRecentlyOpened': return this.service.getRecentlyOpened(arg);
5959
case 'isFocused': return this.service.isFocused(arg);
6060
case 'openExtensionDevelopmentHostWindow': return (this.service as any).openExtensionDevelopmentHostWindow(arg[0], arg[1]); // TODO@Isidor move
61-
case 'getActiveWindowId': return this.service.getActiveWindowId();
6261
}
6362

6463
throw new Error(`Call not found: ${command}`);

src/vs/platform/windows/electron-browser/windowsService.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,4 @@ export class WindowsService implements IWindowsService {
5757
openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise<void> {
5858
return this.channel.call('openExtensionDevelopmentHostWindow', [args, env]);
5959
}
60-
61-
getActiveWindowId(): Promise<number | undefined> {
62-
return this.channel.call('getActiveWindowId');
63-
}
6460
}

src/vs/platform/windows/electron-main/legacyWindowsMainService.ts

Lines changed: 1 addition & 13 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 { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
6+
import { Disposable } from 'vs/base/common/lifecycle';
77
import { assign } from 'vs/base/common/objects';
88
import { URI } from 'vs/base/common/uri';
99
import { IWindowsService, OpenContext } from 'vs/platform/windows/common/windows';
@@ -23,10 +23,6 @@ export class LegacyWindowsMainService extends Disposable implements IWindowsServ
2323

2424
_serviceBrand: undefined;
2525

26-
private readonly disposables = this._register(new DisposableStore());
27-
28-
private _activeWindowId: number | undefined;
29-
3026
readonly onWindowOpen: Event<number> = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-created', (_, w: BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
3127
readonly onWindowBlur: Event<number> = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-blur', (_, w: BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
3228
readonly onWindowMaximize: Event<number> = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-maximize', (_, w: BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
@@ -48,10 +44,6 @@ export class LegacyWindowsMainService extends Disposable implements IWindowsServ
4844
super();
4945

5046
urlService.registerHandler(this);
51-
52-
// remember last active window id
53-
Event.latch(Event.any(this.onWindowOpen, this.onWindowFocus))
54-
(id => this._activeWindowId = id, null, this.disposables);
5547
}
5648

5749
async addRecentlyOpened(recents: IRecent[]): Promise<void> {
@@ -96,10 +88,6 @@ export class LegacyWindowsMainService extends Disposable implements IWindowsServ
9688
}
9789
}
9890

99-
async getActiveWindowId(): Promise<number | undefined> {
100-
return this._activeWindowId;
101-
}
102-
10391
async handleURL(uri: URI): Promise<boolean> {
10492

10593
// Catch file URLs

src/vs/platform/windows/node/windows.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ export class ActiveWindowManager extends Disposable {
1414
private firstActiveWindowIdPromise: CancelablePromise<number | undefined> | undefined;
1515

1616
private activeWindowId: number | undefined;
17+
private _activeWindowId: number | undefined;
1718

1819
constructor(@IWindowsService windowsService: IWindowsService) {
1920
super();
2021

22+
// remember last active window id
23+
Event.latch(Event.any(windowsService.onWindowOpen, windowsService.onWindowFocus))(id => this._activeWindowId = id, null, this.disposables);
24+
2125
const onActiveWindowChange = Event.latch(Event.any(windowsService.onWindowOpen, windowsService.onWindowFocus));
2226
onActiveWindowChange(this.setActiveWindow, this, this.disposables);
2327

24-
this.firstActiveWindowIdPromise = createCancelablePromise(_ => windowsService.getActiveWindowId());
28+
this.firstActiveWindowIdPromise = createCancelablePromise(_ => this.getActiveWindowId());
2529
this.firstActiveWindowIdPromise
2630
.then(id => this.activeWindowId = typeof this.activeWindowId === 'number' ? this.activeWindowId : id)
2731
.finally(this.firstActiveWindowIdPromise = undefined);
@@ -42,4 +46,7 @@ export class ActiveWindowManager extends Disposable {
4246
return `window:${id}`;
4347
}
4448

49+
private async getActiveWindowId(): Promise<number | undefined> {
50+
return this._activeWindowId;
51+
}
4552
}

src/vs/workbench/browser/web.simpleservices.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ export class SimpleWindowsService implements IWindowsService {
165165
files: []
166166
});
167167
}
168-
169-
getActiveWindowId(): Promise<number | undefined> {
170-
return Promise.resolve(0);
171-
}
172168
}
173169

174170
registerSingleton(IWindowsService, SimpleWindowsService);

src/vs/workbench/test/workbenchTestServices.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,10 +1280,6 @@ export class TestWindowsService implements IWindowsService {
12801280
files: []
12811281
});
12821282
}
1283-
1284-
getActiveWindowId(): Promise<number | undefined> {
1285-
return Promise.resolve(undefined);
1286-
}
12871283
}
12881284

12891285
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

0 commit comments

Comments
 (0)