|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information.
|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 |
| -import { app, BrowserWindow, Display, nativeImage, NativeImage, Rectangle, screen, SegmentedControlSegment, systemPreferences, TouchBar, TouchBarSegmentedControl, WebContents } from 'electron'; |
| 6 | +import { app, BrowserWindow, Display, nativeImage, NativeImage, Rectangle, screen, SegmentedControlSegment, systemPreferences, TouchBar, TouchBarSegmentedControl, WebContents, Event as ElectronEvent } from 'electron'; |
7 | 7 | import { DeferredPromise, RunOnceScheduler, timeout } from 'vs/base/common/async';
|
8 | 8 | import { CancellationToken } from 'vs/base/common/cancellation';
|
9 | 9 | import { toErrorMessage } from 'vs/base/common/errorMessage';
|
@@ -682,29 +682,27 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
|
682 | 682 | private registerListeners(): void {
|
683 | 683 |
|
684 | 684 | // Window error conditions to handle
|
685 |
| - this._win.on('unresponsive', () => this.onWindowError(WindowError.UNRESPONSIVE)); |
686 |
| - this._win.webContents.on('render-process-gone', (event, details) => this.onWindowError(WindowError.PROCESS_GONE, { ...details })); |
687 |
| - this._win.webContents.on('did-fail-load', (event, exitCode, reason) => this.onWindowError(WindowError.LOAD, { reason, exitCode })); |
| 685 | + this._register(Event.fromNodeEventEmitter(this._win, 'unresponsive')(() => this.onWindowError(WindowError.UNRESPONSIVE))); |
| 686 | + this._register(Event.fromNodeEventEmitter(this._win.webContents, 'render-process-gone', (event, details) => details)(details => this.onWindowError(WindowError.PROCESS_GONE, { ...details }))); |
| 687 | + this._register(Event.fromNodeEventEmitter(this._win.webContents, 'did-fail-load', (event, exitCode, reason) => ({ exitCode, reason }))(({ exitCode, reason }) => this.onWindowError(WindowError.LOAD, { reason, exitCode }))); |
688 | 688 |
|
689 | 689 | // Prevent windows/iframes from blocking the unload
|
690 | 690 | // through DOM events. We have our own logic for
|
691 | 691 | // unloading a window that should not be confused
|
692 | 692 | // with the DOM way.
|
693 | 693 | // (https://github.com/microsoft/vscode/issues/122736)
|
694 |
| - this._win.webContents.on('will-prevent-unload', event => { |
695 |
| - event.preventDefault(); |
696 |
| - }); |
| 694 | + this._register(Event.fromNodeEventEmitter<ElectronEvent>(this._win.webContents, 'will-prevent-unload')(event => event.preventDefault())); |
697 | 695 |
|
698 | 696 | // Remember that we loaded
|
699 |
| - this._win.webContents.on('did-finish-load', () => { |
| 697 | + this._register(Event.fromNodeEventEmitter(this._win.webContents, 'did-finish-load')(() => { |
700 | 698 |
|
701 | 699 | // Associate properties from the load request if provided
|
702 | 700 | if (this.pendingLoadConfig) {
|
703 | 701 | this._config = this.pendingLoadConfig;
|
704 | 702 |
|
705 | 703 | this.pendingLoadConfig = undefined;
|
706 | 704 | }
|
707 |
| - }); |
| 705 | + })); |
708 | 706 |
|
709 | 707 | // Window (Un)Maximize
|
710 | 708 | this._register(this.onDidMaximize(() => {
|
|
0 commit comments