mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
onRecoverContext -> onContextLoss
This commit is contained in:
@@ -12,8 +12,8 @@ import { EventEmitter } from 'common/EventEmitter';
|
||||
export class WebglAddon implements ITerminalAddon {
|
||||
private _terminal?: Terminal;
|
||||
private _renderer?: WebglRenderer;
|
||||
private _onRecoverContext = new EventEmitter<void>();
|
||||
public get onRecoverContext(): IEvent<void> { return this._onRecoverContext.event; }
|
||||
private _onContextLoss = new EventEmitter<void>();
|
||||
public get onContextLoss(): IEvent<void> { return this._onContextLoss.event; }
|
||||
|
||||
constructor(
|
||||
private _preserveDrawingBuffer?: boolean
|
||||
@@ -27,7 +27,7 @@ export class WebglAddon implements ITerminalAddon {
|
||||
const renderService: IRenderService = (<any>terminal)._core._renderService;
|
||||
const colors: IColorSet = (<any>terminal)._core._colorManager.colors;
|
||||
this._renderer = new WebglRenderer(terminal, colors, this._preserveDrawingBuffer);
|
||||
this._renderer.onRecoverContext(() => this._onRecoverContext.fire());
|
||||
this._renderer.onContextLoss(() => this._onContextLoss.fire());
|
||||
renderService.setRenderer(this._renderer);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
||||
private _onRequestRedraw = new EventEmitter<IRequestRedrawEvent>();
|
||||
public get onRequestRedraw(): IEvent<IRequestRedrawEvent> { return this._onRequestRedraw.event; }
|
||||
|
||||
private _onRecoverContext = new EventEmitter<void>();
|
||||
public get onRecoverContext(): IEvent<void> { return this._onRecoverContext.event; }
|
||||
private _onContextLoss = new EventEmitter<void>();
|
||||
public get onContextLoss(): IEvent<void> { return this._onContextLoss.event; }
|
||||
|
||||
constructor(
|
||||
private _terminal: Terminal,
|
||||
@@ -87,7 +87,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
||||
throw new Error('WebGL2 not supported ' + this._gl);
|
||||
}
|
||||
|
||||
this.register(addDisposableDomListener(this._canvas, 'webglcontextlost', (e) => { this._onContextLost(e); }));
|
||||
this.register(addDisposableDomListener(this._canvas, 'webglcontextlost', (e) => { this._onContextLoss.fire(e); }));
|
||||
|
||||
this._core.screenElement!.appendChild(this._canvas);
|
||||
|
||||
@@ -100,11 +100,6 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
||||
this._isAttached = document.body.contains(this._core.screenElement!);
|
||||
}
|
||||
|
||||
private _onContextLost(e: Event): void {
|
||||
e.preventDefault();
|
||||
this._onRecoverContext.fire();
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
for (const l of this._renderLayers) {
|
||||
l.dispose();
|
||||
|
||||
Reference in New Issue
Block a user