if (screen && UI.connected) {
var resizeMode = UI.getSetting('resize');
- UI.rfb.scale = 1.0;
+ UI.rfb.viewportScale = 1.0;
// Make sure the viewport is adjusted first
UI.updateViewClip();
updateViewClip: function() {
if (!UI.rfb) return;
- var cur_clip = UI.rfb.viewport;
+ var cur_clip = UI.rfb.clipViewport;
var new_clip = UI.getSetting('view_clip');
var resizeSetting = UI.getSetting('resize');
}
if (cur_clip !== new_clip) {
- UI.rfb.viewport = new_clip;
+ UI.rfb.clipViewport = new_clip;
}
var size = UI.screenSize();
toggleViewDrag: function() {
if (!UI.rfb) return;
- var drag = UI.rfb.viewportDrag;
+ var drag = UI.rfb.dragViewport;
UI.setViewDrag(!drag);
},
setViewDrag: function(drag) {
if (!UI.rfb) return;
- UI.rfb.viewportDrag = drag;
+ UI.rfb.dragViewport = drag;
UI.updateViewDrag();
},
// Check if viewport drag is possible. It is only possible
// if the remote display is clipping the client display.
- if (UI.rfb.viewport && UI.rfb.isClipped) {
+ if (UI.rfb.clipViewport && UI.rfb.isClipped) {
clipping = true;
}
var viewDragButton = document.getElementById('noVNC_view_drag_button');
if (!clipping &&
- UI.rfb.viewportDrag) {
+ UI.rfb.dragViewport) {
// The size of the remote display is the same or smaller
// than the client display. Make sure viewport drag isn't
// active when it can't be used.
- UI.rfb.viewportDrag = false;
+ UI.rfb.dragViewport = false;
}
- if (UI.rfb.viewportDrag) {
+ if (UI.rfb.dragViewport) {
viewDragButton.classList.add("noVNC_selected");
} else {
viewDragButton.classList.remove("noVNC_selected");
this._rescale(scale);
},
- _viewport: false,
- get viewport() { return this._viewport; },
- set viewport(viewport) {
- this._viewport = viewport;
+ _clipViewport: false,
+ get clipViewport() { return this._clipViewport; },
+ set clipViewport(viewport) {
+ this._clipViewport = viewport;
// May need to readjust the viewport dimensions
var vp = this._viewportLoc;
this.viewportChangeSize(vp.w, vp.h);
deltaX = Math.floor(deltaX);
deltaY = Math.floor(deltaY);
- if (!this._viewport) {
+ if (!this._clipViewport) {
deltaX = -vp.w; // clamped later of out of bounds
deltaY = -vp.h;
}
viewportChangeSize: function(width, height) {
- if (!this._viewport ||
+ if (!this._clipViewport ||
typeof(width) === "undefined" ||
typeof(height) === "undefined") {
// ===== PROPERTIES =====
disconnectTimeout: 3,
- viewportDrag: false,
+ dragViewport: false,
_localCursor: false,
get localCursor() { return this._localCursor; },
get touchButton() { return this._mouse.touchButton; },
set touchButton(button) { this._mouse.touchButton = button; },
- get scale() { return this._display.scale; },
- set scale(scale) { this._display.scale = scale; },
+ get viewportScale() { return this._display.scale; },
+ set viewportScale(scale) { this._display.scale = scale; },
- get viewport() { return this._display.viewport; },
- set viewport(viewport) { this._display.viewport = viewport; },
+ get clipViewport() { return this._display.clipViewport; },
+ set clipViewport(viewport) { this._display.clipViewport = viewport; },
get isClipped() { return this._display.isClipped; },
this._mouse_buttonMask &= ~bmask;
}
- if (this._viewportDrag) {
+ if (this.dragViewport) {
if (down && !this._viewportDragging) {
this._viewportDragging = true;
this._viewportDragPos = {'x': x, 'y': y};
### 2.3.1 Configuration Attributes
-| name | type | mode | default | description
-| ----------- | ----- | ---- | ------- | ------------
-| logo | raw | RW | | Logo to display when cleared: {"width": width, "height": height, "type": mime-type, "data": data}
-| scale | float | RW | 1.0 | Display area scale factor 0.0 - 1.0
-| viewport | bool | RW | false | Use viewport clipping
-| width | int | RO | | Display area width
-| height | int | RO | | Display area height
-| isClipped | bool | RO | | Is the remote display is larger than the client display
+| name | type | mode | default | description
+| ------------ | ----- | ---- | ------- | ------------
+| logo | raw | RW | | Logo to display when cleared: {"width": width, "height": height, "type": mime-type, "data": data}
+| scale | float | RW | 1.0 | Display area scale factor 0.0 - 1.0
+| clipViewport | bool | RW | false | Use viewport clipping
+| width | int | RO | | Display area width
+| height | int | RO | | Display area height
+| isClipped | bool | RO | | Is the remote display is larger than the client display
### 2.3.2 Methods
[`MouseEvent.button`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button).
Is set to `1` by default.
-`scale`
+`viewportScale`
- Is a `double` indicating how the framebuffer contents should be
scaled before being rendered on to the canvas. See also
[`RFB.autoscale()`](#rfbautoscale). Is set to `1.0` by default.
-`viewport`
+`clipViewport`
- Is a `boolean` indicating if the canvas should be clipped to its
container. When disabled the container must be able to handle the
resulting overflow. Disabled by default.
-`viewportDrag`
+`dragViewport`
- Is a `boolean` indicating if mouse events should control the
- relative position of a clipped canvas. Only relevant if `viewport`
- is enabled. Disabled by default.
+ relative position of a clipped canvas. Only relevant if
+ `clipViewport` is enabled. Disabled by default.
`isClipped` *Read only*
- Is a `boolean` indicating if the framebuffer is larger than the
- Send clipboard contents to server.
[`RFB.autoscale()`](#rfbautoscale)
- - Set `RFB.scale` so that the framebuffer fits a specified container.
+ - Set `RFB.viewportScale` so that the framebuffer fits a specified
+ container.
[`RFB.requestDesktopSize()`](#rfbrequestDesktopSize)
- Send a request to change the remote desktop size.
#### RFB.autoscale()
The `RFB.autoscale()` method is used to automatically adjust
-`RFB.scale` to fit given dimensions.
+`RFB.viewportScale` to fit given dimensions.
##### Syntax
The `RFB.viewportChangeSize()` method is used to change the size of the
canvas rather than the underlying framebuffer.
-This method has no effect if `RFB.viewport` is set to `false`.
+This method has no effect if `RFB.clipViewport` is set to `false`.
##### Syntax
var display;
beforeEach(function () {
display = new Display(document.createElement('canvas'));
- display.viewport = true;
+ display.clipViewport = true;
display.resize(5, 5);
display.viewportChangeSize(3, 3);
display.viewportChangePos(1, 1);
});
it('should show the entire framebuffer when disabling the viewport', function() {
- display.viewport = false;
+ display.clipViewport = false;
expect(display.absX(0)).to.equal(0);
expect(display.absY(0)).to.equal(0);
expect(display._target.width).to.equal(5);
});
it('should ignore viewport changes when the viewport is disabled', function() {
- display.viewport = false;
+ display.clipViewport = false;
display.viewportChangeSize(2, 2);
display.viewportChangePos(1, 1);
expect(display.absX(0)).to.equal(0);
});
it('should show the entire framebuffer just after enabling the viewport', function() {
- display.viewport = false;
- display.viewport = true;
+ display.clipViewport = false;
+ display.clipViewport = true;
expect(display.absX(0)).to.equal(0);
expect(display.absY(0)).to.equal(0);
expect(display._target.width).to.equal(5);
var display;
beforeEach(function () {
display = new Display(document.createElement('canvas'));
- display.viewport = false;
+ display.clipViewport = false;
display.resize(4, 4);
});
describe('viewport', function () {
beforeEach(function () {
- display.viewport = true;
+ display.clipViewport = true;
display.viewportChangeSize(3, 3);
display.viewportChangePos(1, 1);
});
beforeEach(function () {
canvas = document.createElement('canvas');
display = new Display(canvas);
- display.viewport = true;
+ display.clipViewport = true;
display.resize(4, 4);
display.viewportChangeSize(3, 3);
display.viewportChangePos(1, 1);
beforeEach(function () {
canvas = document.createElement('canvas');
display = new Display(canvas);
- display.viewport = true;
+ display.clipViewport = true;
display.resize(4, 3);
document.body.appendChild(canvas);
});
});
it('should not send button messages when initiating viewport dragging', function () {
- client._viewportDrag = true;
+ client.dragViewport = true;
client._handleMouseButton(13, 9, 0x001);
expect(client._sock.flush).to.not.have.been.called;
});
it('should be initiate viewport dragging on a button down event, if enabled', function () {
- client._viewportDrag = true;
+ client.dragViewport = true;
client._handleMouseButton(13, 9, 0x001);
expect(client._viewportDragging).to.be.true;
expect(client._viewportDragPos).to.deep.equal({ x: 13, y: 9 });
});
it('should terminate viewport dragging on a button up event, if enabled', function () {
- client._viewportDrag = true;
+ client.dragViewport = true;
client._viewportDragging = true;
client._handleMouseButton(13, 9, 0x000);
expect(client._viewportDragging).to.be.false;
var newX = 123 + 11 * window.devicePixelRatio;
var newY = 109 + 4 * window.devicePixelRatio;
- client._viewportDrag = true;
+ client.dragViewport = true;
client._viewportDragging = true;
client._viewportHasMoved = false;
client._viewportDragPos = { x: oldX, y: oldY };