Skip to content

Commit 4a44dd5

Browse files
committed
Revert - remove getActiveWindowId change
1 parent d483a31 commit 4a44dd5

7 files changed

Lines changed: 28 additions & 9 deletions

File tree

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

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

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ 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();
6162
}
6263

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

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,8 @@ 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+
}
6064
}

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

Lines changed: 13 additions & 1 deletion
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 } from 'vs/base/common/lifecycle';
6+
import { Disposable, DisposableStore } 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,6 +23,10 @@ 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+
2630
readonly onWindowOpen: Event<number> = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-created', (_, w: BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
2731
readonly onWindowBlur: Event<number> = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-blur', (_, w: BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
2832
readonly onWindowMaximize: Event<number> = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-maximize', (_, w: BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
@@ -44,6 +48,10 @@ export class LegacyWindowsMainService extends Disposable implements IWindowsServ
4448
super();
4549

4650
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);
4755
}
4856

4957
async addRecentlyOpened(recents: IRecent[]): Promise<void> {
@@ -88,6 +96,10 @@ export class LegacyWindowsMainService extends Disposable implements IWindowsServ
8896
}
8997
}
9098

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

93105
// Catch file URLs

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

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

1616
private activeWindowId: number | undefined;
17-
private _activeWindowId: number | undefined;
1817

1918
constructor(@IWindowsService windowsService: IWindowsService) {
2019
super();
2120

22-
// remember last active window id
23-
Event.latch(Event.any(windowsService.onWindowOpen, windowsService.onWindowFocus))(id => this._activeWindowId = id, null, this.disposables);
24-
2521
const onActiveWindowChange = Event.latch(Event.any(windowsService.onWindowOpen, windowsService.onWindowFocus));
2622
onActiveWindowChange(this.setActiveWindow, this, this.disposables);
2723

28-
this.firstActiveWindowIdPromise = createCancelablePromise(_ => this.getActiveWindowId());
24+
this.firstActiveWindowIdPromise = createCancelablePromise(_ => windowsService.getActiveWindowId());
2925
this.firstActiveWindowIdPromise
3026
.then(id => this.activeWindowId = typeof this.activeWindowId === 'number' ? this.activeWindowId : id)
3127
.finally(this.firstActiveWindowIdPromise = undefined);
@@ -46,7 +42,4 @@ export class ActiveWindowManager extends Disposable {
4642
return `window:${id}`;
4743
}
4844

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

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

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

170174
registerSingleton(IWindowsService, SimpleWindowsService);

src/vs/workbench/test/workbenchTestServices.ts

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

12851289
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

0 commit comments

Comments
 (0)