Listen to dpr change in a11y manager
This commit is contained in:
@@ -66,6 +66,10 @@ export class AccessibilityManager implements IDisposable {
|
|||||||
this._addTerminalEventListener('charsizechanged', () => this._refreshRowsDimensions());
|
this._addTerminalEventListener('charsizechanged', () => this._refreshRowsDimensions());
|
||||||
this._addTerminalEventListener('key', keyChar => this._onKey(keyChar));
|
this._addTerminalEventListener('key', keyChar => this._onKey(keyChar));
|
||||||
this._addTerminalEventListener('blur', () => this._clearLiveRegion());
|
this._addTerminalEventListener('blur', () => this._clearLiveRegion());
|
||||||
|
// TODO: Maybe renderer should fire an event on terminal when the characters change and that
|
||||||
|
// should be listened to instead? That would mean that the order of events are always
|
||||||
|
// guarenteed
|
||||||
|
this._addTerminalEventListener('dprchange', () => this._refreshRowsDimensions());
|
||||||
// TODO: Dispose of this listener when disposed
|
// TODO: Dispose of this listener when disposed
|
||||||
// TODO: Listen instead to when devicePixelRatio changed (depends on PR #1172)
|
// TODO: Listen instead to when devicePixelRatio changed (depends on PR #1172)
|
||||||
window.addEventListener('resize', () => this._refreshRowsDimensions());
|
window.addEventListener('resize', () => this._refreshRowsDimensions());
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import { MouseZoneManager } from './input/MouseZoneManager';
|
|||||||
import { initialize as initializeCharAtlas } from './renderer/CharAtlas';
|
import { initialize as initializeCharAtlas } from './renderer/CharAtlas';
|
||||||
import { IRenderer } from './renderer/Interfaces';
|
import { IRenderer } from './renderer/Interfaces';
|
||||||
import { AccessibilityManager } from './AccessibilityManager';
|
import { AccessibilityManager } from './AccessibilityManager';
|
||||||
|
import { ScreenDprMonitor } from './utils/ScreenDprMonitor';
|
||||||
|
|
||||||
// Let it work inside Node.js for automated testing purposes.
|
// Let it work inside Node.js for automated testing purposes.
|
||||||
const document = (typeof window !== 'undefined') ? window.document : null;
|
const document = (typeof window !== 'undefined') ? window.document : null;
|
||||||
@@ -201,6 +202,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
private _mouseZoneManager: IMouseZoneManager;
|
private _mouseZoneManager: IMouseZoneManager;
|
||||||
public mouseHelper: MouseHelper;
|
public mouseHelper: MouseHelper;
|
||||||
private _accessibilityManager: AccessibilityManager;
|
private _accessibilityManager: AccessibilityManager;
|
||||||
|
private _screenDprMonitor: ScreenDprMonitor;
|
||||||
|
|
||||||
public cols: number;
|
public cols: number;
|
||||||
public rows: number;
|
public rows: number;
|
||||||
@@ -586,6 +588,9 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
|
|
||||||
initializeCharAtlas(this.document);
|
initializeCharAtlas(this.document);
|
||||||
|
|
||||||
|
this._screenDprMonitor = new ScreenDprMonitor();
|
||||||
|
this._screenDprMonitor.setListener(() => this.emit('dprchange', window.devicePixelRatio));
|
||||||
|
|
||||||
// Create main element container
|
// Create main element container
|
||||||
this.element = this.document.createElement('div');
|
this.element = this.document.createElement('div');
|
||||||
this.element.classList.add('terminal');
|
this.element.classList.add('terminal');
|
||||||
@@ -647,6 +652,10 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
this.on('resize', () => this.renderer.onResize(this.cols, this.rows, false));
|
this.on('resize', () => this.renderer.onResize(this.cols, this.rows, false));
|
||||||
this.on('blur', () => this.renderer.onBlur());
|
this.on('blur', () => this.renderer.onBlur());
|
||||||
this.on('focus', () => this.renderer.onFocus());
|
this.on('focus', () => this.renderer.onFocus());
|
||||||
|
this.on('dprchange', () => this.renderer.onWindowResize(window.devicePixelRatio));
|
||||||
|
// dprchange should handle this case, we need this as well for browsers that don't support the
|
||||||
|
// matchMedia query.
|
||||||
|
window.addEventListener('resize', () => this.renderer.onWindowResize(window.devicePixelRatio));
|
||||||
this.charMeasure.on('charsizechanged', () => this.renderer.onResize(this.cols, this.rows, true));
|
this.charMeasure.on('charsizechanged', () => this.renderer.onResize(this.cols, this.rows, true));
|
||||||
this.renderer.on('resize', (dimensions) => this.viewport.syncScrollArea());
|
this.renderer.on('resize', (dimensions) => this.viewport.syncScrollArea());
|
||||||
|
|
||||||
@@ -670,6 +679,8 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
this.mouseHelper = new MouseHelper(this.renderer);
|
this.mouseHelper = new MouseHelper(this.renderer);
|
||||||
|
|
||||||
if (this.options.screenReaderMode) {
|
if (this.options.screenReaderMode) {
|
||||||
|
// Note that this must be done *after* the renderer is created in order to
|
||||||
|
// ensure the correct order of the dprchange event
|
||||||
this._accessibilityManager = new AccessibilityManager(this);
|
this._accessibilityManager = new AccessibilityManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,14 +14,12 @@ import { IRenderLayer, IColorSet, IRenderer, IRenderDimensions } from './Interfa
|
|||||||
import { LinkRenderLayer } from './LinkRenderLayer';
|
import { LinkRenderLayer } from './LinkRenderLayer';
|
||||||
import { EventEmitter } from '../EventEmitter';
|
import { EventEmitter } from '../EventEmitter';
|
||||||
import { RenderDebouncer } from '../utils/RenderDebouncer';
|
import { RenderDebouncer } from '../utils/RenderDebouncer';
|
||||||
import { ScreenDprMonitor } from '../utils/ScreenDprMonitor';
|
|
||||||
|
|
||||||
export class Renderer extends EventEmitter implements IRenderer {
|
export class Renderer extends EventEmitter implements IRenderer {
|
||||||
private _renderDebouncer: RenderDebouncer;
|
private _renderDebouncer: RenderDebouncer;
|
||||||
|
|
||||||
private _renderLayers: IRenderLayer[];
|
private _renderLayers: IRenderLayer[];
|
||||||
private _devicePixelRatio: number;
|
private _devicePixelRatio: number;
|
||||||
private _screenDprMonitor: ScreenDprMonitor;
|
|
||||||
private _isPaused: boolean = false;
|
private _isPaused: boolean = false;
|
||||||
private _needsFullRefresh: boolean = false;
|
private _needsFullRefresh: boolean = false;
|
||||||
|
|
||||||
@@ -58,9 +56,6 @@ export class Renderer extends EventEmitter implements IRenderer {
|
|||||||
this._updateDimensions();
|
this._updateDimensions();
|
||||||
this._renderDebouncer = new RenderDebouncer(this._terminal, this._renderRows.bind(this));
|
this._renderDebouncer = new RenderDebouncer(this._terminal, this._renderRows.bind(this));
|
||||||
|
|
||||||
this._screenDprMonitor = new ScreenDprMonitor();
|
|
||||||
this._screenDprMonitor.setListener(() => this.onWindowResize(window.devicePixelRatio));
|
|
||||||
|
|
||||||
// Detect whether IntersectionObserver is detected and enable renderer pause
|
// Detect whether IntersectionObserver is detected and enable renderer pause
|
||||||
// and resume based on terminal visibility if so
|
// and resume based on terminal visibility if so
|
||||||
if ('IntersectionObserver' in window) {
|
if ('IntersectionObserver' in window) {
|
||||||
|
|||||||
Reference in New Issue
Block a user