Fixes #138240: Use matchMedia to detect device pixel ratio changes

This commit is contained in:
Alexandru Dima
2022-01-12 22:07:48 +01:00
parent dce080bba5
commit acac174fe4
12 changed files with 106 additions and 53 deletions

View File

@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import * as dom from 'vs/base/browser/dom';
import * as browser from 'vs/base/browser/browser';
import { Selection } from 'vs/editor/common/core/selection';
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
@@ -67,7 +66,6 @@ export class View extends ViewEventHandler {
private readonly _scrollbar: EditorScrollbar;
private readonly _context: ViewContext;
private _configPixelRatio: number;
private _selections: Selection[];
// The view lines
@@ -107,7 +105,6 @@ export class View extends ViewEventHandler {
// The view context is passed on to most classes (basically to reduce param. counts in ctors)
this._context = new ViewContext(configuration, themeService.getColorTheme(), model);
this._configPixelRatio = this._context.configuration.options.get(EditorOption.pixelRatio);
// Ensure the view is the first event handler in order to update the layout
this._context.addEventHandler(this);
@@ -306,7 +303,6 @@ export class View extends ViewEventHandler {
this._scheduleRender();
}
public override onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
this._configPixelRatio = this._context.configuration.options.get(EditorOption.pixelRatio);
this.domNode.setClassName(this._getEditorClassName());
this._applyLayout();
return false;
@@ -418,12 +414,6 @@ export class View extends ViewEventHandler {
viewPart.render(renderingContext);
viewPart.onDidRender();
}
// Try to detect browser zooming and paint again if necessary
if (Math.abs(browser.getPixelRatio() - this._configPixelRatio) > 0.001) {
// looks like the pixel ratio has changed
this._context.configuration.observePixelRatio();
}
}
// --- BEGIN CodeEditor helpers