mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
fix formatting
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { Disposable, MutableDisposable, toDisposable } from "common/Lifecycle";
|
||||
import { ICoreBrowserService } from "./Services";
|
||||
import { EventEmitter, forwardEvent } from "common/EventEmitter";
|
||||
import { addDisposableDomListener } from "browser/Lifecycle";
|
||||
import { Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
|
||||
import { ICoreBrowserService } from './Services';
|
||||
import { EventEmitter, forwardEvent } from 'common/EventEmitter';
|
||||
import { addDisposableDomListener } from 'browser/Lifecycle';
|
||||
|
||||
export class CoreBrowserService extends Disposable implements ICoreBrowserService {
|
||||
public serviceBrand: undefined;
|
||||
@@ -28,11 +28,15 @@ export class CoreBrowserService extends Disposable implements ICoreBrowserServic
|
||||
super();
|
||||
|
||||
// Monitor device pixel ratio
|
||||
this.register(this.onWindowChange((w) => this._screenDprMonitor.setWindow(w)));
|
||||
this.register(this.onWindowChange(w => this._screenDprMonitor.setWindow(w)));
|
||||
this.register(forwardEvent(this._screenDprMonitor.onDprChange, this._onDprChange));
|
||||
|
||||
this.register(addDisposableDomListener(this._textarea, 'focus', () => (this._isFocused = true)))
|
||||
this.register(addDisposableDomListener(this._textarea, 'blur', () => (this._isFocused = false)))
|
||||
this.register(
|
||||
addDisposableDomListener(this._textarea, 'focus', () => (this._isFocused = true))
|
||||
);
|
||||
this.register(
|
||||
addDisposableDomListener(this._textarea, 'blur', () => (this._isFocused = false))
|
||||
);
|
||||
}
|
||||
|
||||
public get window(): Window & typeof globalThis {
|
||||
@@ -53,12 +57,13 @@ export class CoreBrowserService extends Disposable implements ICoreBrowserServic
|
||||
public get isFocused(): boolean {
|
||||
if (this._cachedIsFocused === undefined) {
|
||||
this._cachedIsFocused = this._isFocused && this._textarea.ownerDocument.hasFocus();
|
||||
queueMicrotask(() => (this._cachedIsFocused = undefined));
|
||||
queueMicrotask(() => this._cachedIsFocused = undefined);
|
||||
}
|
||||
return this._cachedIsFocused;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The screen device pixel ratio monitor allows listening for when the
|
||||
* window.devicePixelRatio value changes. This is done not with polling but with
|
||||
@@ -93,6 +98,7 @@ class ScreenDprMonitor extends Disposable {
|
||||
this.register(toDisposable(() => this.clearListener()));
|
||||
}
|
||||
|
||||
|
||||
public setWindow(parentWindow: Window): void {
|
||||
this._parentWindow = parentWindow;
|
||||
this._setWindowResizeListener();
|
||||
@@ -100,7 +106,7 @@ class ScreenDprMonitor extends Disposable {
|
||||
}
|
||||
|
||||
private _setWindowResizeListener(): void {
|
||||
this._windowResizeListener.value = addDisposableDomListener(this._parentWindow, "resize", () =>
|
||||
this._windowResizeListener.value = addDisposableDomListener(this._parentWindow, 'resize', () =>
|
||||
this._setDprAndFireIfDiffers()
|
||||
);
|
||||
}
|
||||
@@ -122,9 +128,7 @@ class ScreenDprMonitor extends Disposable {
|
||||
|
||||
// Add listeners for new DPR
|
||||
this._currentDevicePixelRatio = this._parentWindow.devicePixelRatio;
|
||||
this._resolutionMediaMatchList = this._parentWindow.matchMedia(
|
||||
`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`
|
||||
);
|
||||
this._resolutionMediaMatchList = this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`);
|
||||
this._resolutionMediaMatchList.addListener(this._outerListener);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user