Merge branch 'hidpi_scale' of https://github.com/CendioOssman/noVNC
This commit is contained in:
commit
ce6287574f
|
@ -168,6 +168,9 @@ export default class Display {
|
||||||
height = this._fb_height;
|
height = this._fb_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
width = Math.floor(width);
|
||||||
|
height = Math.floor(height);
|
||||||
|
|
||||||
if (width > this._fb_width) {
|
if (width > this._fb_width) {
|
||||||
width = this._fb_width;
|
width = this._fb_width;
|
||||||
}
|
}
|
||||||
|
@ -524,8 +527,8 @@ export default class Display {
|
||||||
// style width to a number, the canvas is cleared.
|
// style width to a number, the canvas is cleared.
|
||||||
// However, if you set the style width to a string
|
// However, if you set the style width to a string
|
||||||
// ('NNNpx'), the canvas is scaled without clearing.
|
// ('NNNpx'), the canvas is scaled without clearing.
|
||||||
const width = Math.round(factor * vp.w) + 'px';
|
const width = factor * vp.w + 'px';
|
||||||
const height = Math.round(factor * vp.h) + 'px';
|
const height = factor * vp.h + 'px';
|
||||||
|
|
||||||
if ((this._target.style.width !== width) ||
|
if ((this._target.style.width !== width) ||
|
||||||
(this._target.style.height !== height)) {
|
(this._target.style.height !== height)) {
|
||||||
|
|
|
@ -547,7 +547,8 @@ export default class RFB extends EventTargetMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
const size = this._screenSize();
|
const size = this._screenSize();
|
||||||
RFB.messages.setDesktopSize(this._sock, size.w, size.h,
|
RFB.messages.setDesktopSize(this._sock,
|
||||||
|
Math.floor(size.w), Math.floor(size.h),
|
||||||
this._screen_id, this._screen_flags);
|
this._screen_id, this._screen_flags);
|
||||||
|
|
||||||
Log.Debug('Requested new desktop size: ' +
|
Log.Debug('Requested new desktop size: ' +
|
||||||
|
@ -556,8 +557,8 @@ export default class RFB extends EventTargetMixin {
|
||||||
|
|
||||||
// Gets the the size of the available screen
|
// Gets the the size of the available screen
|
||||||
_screenSize() {
|
_screenSize() {
|
||||||
return { w: this._screen.offsetWidth,
|
let r = this._screen.getBoundingClientRect();
|
||||||
h: this._screen.offsetHeight };
|
return { w: r.width, h: r.height };
|
||||||
}
|
}
|
||||||
|
|
||||||
_fixScrollbars() {
|
_fixScrollbars() {
|
||||||
|
|
|
@ -5,12 +5,23 @@ import Mouse from '../core/input/mouse.js';
|
||||||
describe('Mouse Event Handling', function() {
|
describe('Mouse Event Handling', function() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// This function is only used on target (the canvas)
|
let target;
|
||||||
// and for these tests we can assume that the canvas is 100x100
|
|
||||||
// located at coordinates 10x10
|
beforeEach(function () {
|
||||||
sinon.stub(Element.prototype, 'getBoundingClientRect').returns(
|
// For these tests we can assume that the canvas is 100x100
|
||||||
{left: 10, right: 110, top: 10, bottom: 110, width: 100, height: 100});
|
// located at coordinates 10x10
|
||||||
const target = document.createElement('canvas');
|
target = document.createElement('canvas');
|
||||||
|
target.style.position = "absolute";
|
||||||
|
target.style.top = "10px";
|
||||||
|
target.style.left = "10px";
|
||||||
|
target.style.width = "100px";
|
||||||
|
target.style.height = "100px";
|
||||||
|
document.body.appendChild(target);
|
||||||
|
});
|
||||||
|
afterEach(function () {
|
||||||
|
document.body.removeChild(target);
|
||||||
|
target = null;
|
||||||
|
});
|
||||||
|
|
||||||
// The real constructors might not work everywhere we
|
// The real constructors might not work everywhere we
|
||||||
// want to run these tests
|
// want to run these tests
|
||||||
|
|
Loading…
Reference in New Issue