Fix native resolution on hdpi screens
This commit is contained in:
parent
954428d6c8
commit
19e8e924c2
|
@ -245,13 +245,13 @@ export default class Display {
|
|||
this._screens[i].serverWidth = width;
|
||||
this._screens[i].serverHeight = height;
|
||||
this._screens[i].scale = scale;
|
||||
this._screens[i].x2 = this._screens[i].x + this._screens[i].width;
|
||||
this._screens[i].y2 = this._screens[i].y + this._screens[i].height;
|
||||
this._screens[i].x2 = this._screens[i].x + this._screens[i].serverWidth;
|
||||
this._screens[i].y2 = this._screens[i].y + this._screens[i].serverHeight;
|
||||
}
|
||||
|
||||
for (let i = 0; i < this._screens.length; i++) {
|
||||
data.serverWidth = Math.max(data.serverWidth, this._screens[i].x + this._screens[i].width);
|
||||
data.serverHeight = Math.max(data.serverHeight, this._screens[i].y + this._screens[i].height);
|
||||
data.serverWidth = Math.max(data.serverWidth, this._screens[i].x + this._screens[i].serverWidth);
|
||||
data.serverHeight = Math.max(data.serverHeight, this._screens[i].y + this._screens[i].serverHeight);
|
||||
}
|
||||
|
||||
data.screens = this._screens;
|
||||
|
@ -296,7 +296,7 @@ export default class Display {
|
|||
//New Screen, add to far right until user repositions it
|
||||
let x = 0;
|
||||
for (let i = 0; i < this._screens.length; i++) {
|
||||
x = Math.max(x, this._screens[i].x + this._screens[i].width);
|
||||
x = Math.max(x, this._screens[i].x + this._screens[i].serverWidth);
|
||||
}
|
||||
|
||||
var new_screen = {
|
||||
|
@ -1038,7 +1038,7 @@ export default class Display {
|
|||
rect.inSecondary = false;
|
||||
for (let i=0; i < this._screens.length; i++) {
|
||||
let screen = this._screens[i];
|
||||
|
||||
|
||||
if (
|
||||
!((rect.x > screen.x2 || screen.x > (rect.x + rect.width)) && (rect.y > screen.y2 || screen.y > (rect.y + rect.height)))
|
||||
) {
|
||||
|
@ -1071,8 +1071,8 @@ export default class Display {
|
|||
// style width to a number, the canvas is cleared.
|
||||
// However, if you set the style width to a string
|
||||
// ('NNNpx'), the canvas is scaled without clearing.
|
||||
const width = factor * vp.width + 'px';
|
||||
const height = factor * vp.height + 'px';
|
||||
const width = factor * vp.serverWidth + 'px';
|
||||
const height = factor * vp.serverHeight + 'px';
|
||||
|
||||
if ((this._target.style.width !== width) ||
|
||||
(this._target.style.height !== height)) {
|
||||
|
@ -1080,7 +1080,7 @@ export default class Display {
|
|||
this._target.style.height = height;
|
||||
}
|
||||
|
||||
Log.Info('Pixel Ratio: ' + window.devicePixelRatio + ', VNC Scale: ' + factor + 'VNC Res: ' + vp.width + 'x' + vp.height);
|
||||
Log.Info('Pixel Ratio: ' + window.devicePixelRatio + ', VNC Scale: ' + factor + 'VNC Res: ' + vp.serverWidth + 'x' + vp.serverHeight);
|
||||
|
||||
var pixR = Math.abs(Math.ceil(window.devicePixelRatio));
|
||||
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
||||
|
|
16
core/rfb.js
16
core/rfb.js
|
@ -728,6 +728,10 @@ export default class RFB extends EventTargetMixin {
|
|||
if (value !== this._hiDpi) {
|
||||
this._hiDpi = value;
|
||||
this._requestRemoteResize();
|
||||
if (this._display.screens.length > 1) {
|
||||
//force secondary displays to re-register and thus apply new hdpi setting
|
||||
this._proxyRFBMessage('forceResize', [ value ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -741,7 +745,7 @@ export default class RFB extends EventTargetMixin {
|
|||
|
||||
applyScreenPlan(screenPlan) {
|
||||
if (this._isPrimaryDisplay) {
|
||||
let fullPlan = this._display.getScreenSize();
|
||||
let fullPlan = this._screenSize();
|
||||
|
||||
//check plan for validity
|
||||
let minX = Number.MAX_SAFE_INTEGER, minY = Number.MAX_SAFE_INTEGER;
|
||||
|
@ -773,7 +777,7 @@ export default class RFB extends EventTargetMixin {
|
|||
}
|
||||
|
||||
getScreenPlan() {
|
||||
let fullPlan = this._display.getScreenSize();
|
||||
let fullPlan = this._screenSize();
|
||||
let sanitizedPlan = {
|
||||
screens: [],
|
||||
serverWidth: fullPlan.serverWidth,
|
||||
|
@ -1457,7 +1461,7 @@ export default class RFB extends EventTargetMixin {
|
|||
this._display.scale = 1.0;
|
||||
} else {
|
||||
const size = this._screenSize(false);
|
||||
this._display.autoscale(size.screens[0].containerWidth, size.screens[0].containerHeight, size.screens[0].scale);
|
||||
this._display.autoscale(size.screens[0].serverWidth, size.screens[0].serverHeight, size.screens[0].scale);
|
||||
}
|
||||
this._fixScrollbars();
|
||||
}
|
||||
|
@ -1691,8 +1695,6 @@ export default class RFB extends EventTargetMixin {
|
|||
// The following are primary to secondary messages that should be ignored on the primary
|
||||
case 'updateCursor':
|
||||
break;
|
||||
default:
|
||||
Log.Warn(`Unhandled message type (${event.data.eventType}) from control channel.`);
|
||||
}
|
||||
} else {
|
||||
// Primary to secondary screen message
|
||||
|
@ -1704,6 +1706,10 @@ export default class RFB extends EventTargetMixin {
|
|||
break;
|
||||
case 'disconnect':
|
||||
this.disconnect();
|
||||
case 'forceResize':
|
||||
this._hiDpi = event.data.args[0];
|
||||
this._updateScale();
|
||||
this._requestRemoteResize();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue