allow custom scale values
This commit is contained in:
parent
8715ed9e70
commit
248fa10c3d
14
core/rfb.js
14
core/rfb.js
|
|
@ -287,6 +287,7 @@ export default class RFB extends EventTargetMixin {
|
|||
this._viewOnly = false;
|
||||
this._clipViewport = false;
|
||||
this._scaleViewport = false;
|
||||
this._customScale = null;
|
||||
this._resizeSession = false;
|
||||
|
||||
this._showDotCursor = false;
|
||||
|
|
@ -326,8 +327,19 @@ export default class RFB extends EventTargetMixin {
|
|||
this._updateClip();
|
||||
}
|
||||
|
||||
get customScale() { return this._customScale; }
|
||||
set customScale(level) {
|
||||
this._customScale = level;
|
||||
if (level) {
|
||||
this.scaleViewport = false;
|
||||
}
|
||||
}
|
||||
|
||||
get scaleViewport() { return this._scaleViewport; }
|
||||
set scaleViewport(scale) {
|
||||
if (scale) {
|
||||
this.customScale = null;
|
||||
}
|
||||
this._scaleViewport = scale;
|
||||
// Scaling trumps clipping, so we may need to adjust
|
||||
// clipping when enabling or disabling scaling
|
||||
|
|
@ -742,7 +754,7 @@ export default class RFB extends EventTargetMixin {
|
|||
|
||||
_updateScale() {
|
||||
if (!this._scaleViewport) {
|
||||
this._display.scale = 1.0;
|
||||
this._display.scale = this._customScale || 1.0;
|
||||
} else {
|
||||
const size = this._screenSize();
|
||||
this._display.autoscale(size.w, size.h);
|
||||
|
|
|
|||
|
|
@ -741,6 +741,21 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||
expect(spy.set).to.have.been.calledWith(false);
|
||||
});
|
||||
|
||||
it('should update the custom scale setting when changing the property', function () {
|
||||
client.customScale = 1.5;
|
||||
|
||||
const spy = sinon.spy(client, "customScale", ["set"]);
|
||||
|
||||
client.scaleViewport = false;
|
||||
expect(spy.set).to.not.have.been.called;
|
||||
|
||||
spy.set.resetHistory();
|
||||
|
||||
client.scaleViewport = true;
|
||||
expect(spy.set).to.have.been.calledOnce;
|
||||
expect(spy.set).to.have.been.calledWith(null);
|
||||
});
|
||||
|
||||
it('should update the scaling when the container size changes', function () {
|
||||
sinon.spy(client._display, "autoscale");
|
||||
|
||||
|
|
@ -787,6 +802,34 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Custom Scale', function () {
|
||||
let client;
|
||||
beforeEach(function () {
|
||||
client = makeRFB();
|
||||
container.style.width = '70px';
|
||||
container.style.height = '80px';
|
||||
client.scaleViewport = true;
|
||||
});
|
||||
|
||||
it('should update display scale factor when setting the property', function () {
|
||||
const spy = sinon.spy(client._display, "scale", ["set"]);
|
||||
sinon.spy(client._display, "autoscale");
|
||||
|
||||
client.customScale = 1.5;
|
||||
expect(spy.set).to.have.been.calledOnce;
|
||||
expect(spy.set).to.have.been.calledWith(1.5);
|
||||
expect(client._display.autoscale).to.not.have.been.called;
|
||||
});
|
||||
|
||||
it('should not update display scale factor when nullifying the property', function () {
|
||||
const spy = sinon.spy(client._display, "scale", ["set"]);
|
||||
|
||||
client.customScale = null;
|
||||
expect(spy.set).to.not.have.been.called;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Remote resize', function () {
|
||||
let client;
|
||||
beforeEach(function () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue