diff --git a/core/display.js b/core/display.js index 0f567017..1e197bd9 100644 --- a/core/display.js +++ b/core/display.js @@ -418,13 +418,12 @@ export default class Display { this._damage(x, y, w, h); } - autoscale(containerWidth, containerHeight) { - let scaleRatio; + autoscale(containerWidth, containerHeight, scaleRatio=0) { if (containerWidth === 0 || containerHeight === 0) { scaleRatio = 0; - } else { + } else if (scaleRatio === 0) { const vp = this._viewportLoc; const targetAspectRatio = containerWidth / containerHeight; @@ -459,7 +458,7 @@ export default class Display { this._target.style.height = height; } - Log.Debug('Pixel Ratio: ' + window.devicePixelRatio + ', VNC Scale: ' + factor + 'VNC Res: ' + vp.w + 'x' + vp.h); + Log.Info('Pixel Ratio: ' + window.devicePixelRatio + ', VNC Scale: ' + factor + 'VNC Res: ' + vp.w + 'x' + vp.h); var pixR = Math.abs(Math.ceil(window.devicePixelRatio)); var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; diff --git a/core/rfb.js b/core/rfb.js index 7fc5388f..dc36315e 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -1031,7 +1031,7 @@ export default class RFB extends EventTargetMixin { this._display.scale = 1.0; } else { const size = this._screenSize(false); - this._display.autoscale(size.w, size.h); + this._display.autoscale(size.w, size.h, size.scale); } this._fixScrollbars(); } @@ -1065,6 +1065,7 @@ export default class RFB extends EventTargetMixin { } var x = this._screen.offsetWidth; var y = this._screen.offsetHeight; + var scale = 0; // 0=auto try { if (x > 1280 && limited && this.videoQuality == 1) { var ratio = y / x; @@ -1075,13 +1076,25 @@ export default class RFB extends EventTargetMixin { else if (limited && this.videoQuality == 0){ x = 1280; y = 720; + } else if (this._display.antiAliasing === 0 && window.devicePixelRatio > 1 && x < 1000 && x > 0) { + // small device with high resolution, browser is essentially zooming greater than 200% + Log.Info('Device Pixel ratio: ' + window.devicePixelRatio + ' Reported Resolution: ' + x + 'x' + y); + let targetDevicePixelRatio = 1.5; + if (window.devicePixelRatio > 2) { targetDevicePixelRatio = 2; } + let scaledWidth = (x * window.devicePixelRatio) * (1 / targetDevicePixelRatio); + let scaleRatio = scaledWidth / x; + x = x * scaleRatio; + y = y * scaleRatio; + scale = 1 / scaleRatio; + Log.Info('Small device with hDPI screen detected, auto scaling at ' + scaleRatio + ' to ' + x + 'x' + y); } } catch (err) { Log.Debug(err); } return { w: x, - h: y }; + h: y, + scale: scale }; } _fixScrollbars() {