Move ScreenDprMonitor into CoreBrowserService
This commit is contained in:
@@ -5,25 +5,31 @@
|
||||
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { ICoreBrowserService } from './Services';
|
||||
import { EventEmitter } from 'common/EventEmitter';
|
||||
import { EventEmitter, forwardEvent } from 'common/EventEmitter';
|
||||
import { ScreenDprMonitor } from 'browser/ScreenDprMonitor';
|
||||
|
||||
export class CoreBrowserService extends Disposable implements ICoreBrowserService {
|
||||
public serviceBrand: undefined;
|
||||
|
||||
private _isFocused = false;
|
||||
private _cachedIsFocused: boolean | undefined = undefined;
|
||||
private _screenDprMonitor = new ScreenDprMonitor(this._window);
|
||||
|
||||
private readonly _onDprChange = this.register(new EventEmitter<number>());
|
||||
public readonly onDprChange = this._onDprChange.event;
|
||||
private readonly _onWindowChange = this.register(new EventEmitter<Window & typeof globalThis>());
|
||||
public readonly onWindowChange = this._onWindowChange.event;
|
||||
|
||||
constructor(
|
||||
private _textarea: HTMLTextAreaElement,
|
||||
// TODO: Add getter and setter and event
|
||||
private _window: Window & typeof globalThis,
|
||||
public readonly mainDocument: Document
|
||||
) {
|
||||
super();
|
||||
|
||||
this.register(this.onWindowChange(w => this._screenDprMonitor.setWindow(w)));
|
||||
this.register(forwardEvent(this._screenDprMonitor.onDprChange, this._onDprChange));
|
||||
|
||||
this._textarea.addEventListener('focus', () => this._isFocused = true);
|
||||
this._textarea.addEventListener('blur', () => this._isFocused = false);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import { addDisposableDomListener } from 'browser/Lifecycle';
|
||||
import { RenderDebouncer } from 'browser/RenderDebouncer';
|
||||
import { ScreenDprMonitor } from 'browser/ScreenDprMonitor';
|
||||
import { IRenderDebouncerWithCallback } from 'browser/Types';
|
||||
import { IRenderDimensions, IRenderer } from 'browser/renderer/shared/Types';
|
||||
import { ICharSizeService, ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
|
||||
@@ -25,7 +24,6 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
|
||||
private _renderer: MutableDisposable<IRenderer> = this.register(new MutableDisposable());
|
||||
private _renderDebouncer: IRenderDebouncerWithCallback;
|
||||
private _screenDprMonitor: ScreenDprMonitor;
|
||||
private _pausedResizeTask = new DebouncedIdleTask();
|
||||
|
||||
private _isPaused: boolean = false;
|
||||
@@ -67,8 +65,7 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
this._renderDebouncer = new RenderDebouncer(coreBrowserService.window, (start, end) => this._renderRows(start, end));
|
||||
this.register(this._renderDebouncer);
|
||||
|
||||
this._screenDprMonitor = this.register(instantiationService.createInstance(ScreenDprMonitor));
|
||||
this.register(this._screenDprMonitor.onDprChange(() => this.handleDevicePixelRatioChange()));
|
||||
this.register(coreBrowserService.onDprChange(() => this.handleDevicePixelRatioChange()));
|
||||
|
||||
this.register(bufferService.onResize(() => this._fullRefresh()));
|
||||
this.register(bufferService.buffers.onBufferActivate(() => this._renderer.value?.clear()));
|
||||
|
||||
@@ -29,7 +29,9 @@ export interface ICoreBrowserService {
|
||||
|
||||
readonly isFocused: boolean;
|
||||
|
||||
onWindowChange: IEvent<Window & typeof globalThis>;
|
||||
readonly onDprChange: IEvent<number>;
|
||||
readonly onWindowChange: IEvent<Window & typeof globalThis>;
|
||||
|
||||
/**
|
||||
* Gets or sets the parent window that the terminal is rendered into. DOM and rendering APIs (e.g.
|
||||
* requestAnimationFrame) should be invoked in the context of this window. This should be set when
|
||||
|
||||
Reference in New Issue
Block a user