Skip to content

Commit 2e94e43

Browse files
author
Benjamin Pasero
committed
1 parent 405eeab commit 2e94e43

4 files changed

Lines changed: 5 additions & 25 deletions

File tree

src/vs/platform/electron/electron-main/electronMainService.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,6 @@ export class ElectronMainService implements IElectronMainService {
157157
}
158158
}
159159

160-
async isWindowFocused(windowId: number | undefined): Promise<boolean> {
161-
const window = this.windowById(windowId);
162-
if (window) {
163-
return window.win.isFocused();
164-
}
165-
166-
return false;
167-
}
168-
169160
async focusWindow(windowId: number | undefined, options?: { windowId?: number; }): Promise<void> {
170161
if (options && typeof options.windowId === 'number') {
171162
windowId = options.windowId;

src/vs/platform/electron/node/electron.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export interface IElectronService {
4343
unmaximizeWindow(): Promise<void>;
4444
minimizeWindow(): Promise<void>;
4545

46-
isWindowFocused(): Promise<boolean>;
4746
focusWindow(options?: { windowId?: number }): Promise<void>;
4847

4948
// Dialogs

src/vs/workbench/services/host/electron-browser/desktopHostService.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,17 @@ export class DesktopHostService extends Disposable implements IHostService {
2424
@IElectronEnvironmentService private readonly electronEnvironmentService: IElectronEnvironmentService
2525
) {
2626
super();
27-
28-
// Resolve initial window focus state
29-
this._hasFocus = document.hasFocus();
30-
electronService.isWindowFocused().then(focused => this._hasFocus = focused);
31-
32-
this.registerListeners();
33-
}
34-
35-
private registerListeners(): void {
36-
this._register(this.onDidChangeFocus(focus => this._hasFocus = focus));
3727
}
3828

3929
get onDidChangeFocus(): Event<boolean> { return this._onDidChangeFocus; }
4030
private _onDidChangeFocus: Event<boolean> = Event.any(
41-
Event.map(Event.filter(this.electronService.onWindowFocus, id => id === this.electronEnvironmentService.windowId), _ => true),
42-
Event.map(Event.filter(this.electronService.onWindowBlur, id => id === this.electronEnvironmentService.windowId), _ => false)
31+
Event.map(Event.filter(this.electronService.onWindowFocus, id => id === this.electronEnvironmentService.windowId), () => this.hasFocus),
32+
Event.map(Event.filter(this.electronService.onWindowBlur, id => id === this.electronEnvironmentService.windowId), () => this.hasFocus)
4333
);
4434

45-
private _hasFocus: boolean;
46-
get hasFocus(): boolean { return this._hasFocus; }
35+
get hasFocus(): boolean {
36+
return document.hasFocus();
37+
}
4738

4839
openWindow(options?: IOpenEmptyWindowOptions): Promise<void>;
4940
openWindow(toOpen: IWindowOpenable[], options?: IOpenWindowOptions): Promise<void>;

src/vs/workbench/test/workbenchTestServices.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,6 @@ export class TestElectronService implements IElectronService {
14041404
async maximizeWindow(): Promise<void> { }
14051405
async unmaximizeWindow(): Promise<void> { }
14061406
async minimizeWindow(): Promise<void> { }
1407-
async isWindowFocused(): Promise<boolean> { return true; }
14081407
async focusWindow(options?: { windowId?: number | undefined; } | undefined): Promise<void> { }
14091408
async showMessageBox(options: Electron.MessageBoxOptions): Promise<Electron.MessageBoxReturnValue> { throw new Error('Method not implemented.'); }
14101409
async showSaveDialog(options: Electron.SaveDialogOptions): Promise<Electron.SaveDialogReturnValue> { throw new Error('Method not implemented.'); }

0 commit comments

Comments
 (0)