Hide display object from RFB callers
This commit is contained in:
parent
6929a0a183
commit
b9854a5ca5
21
app/ui.js
21
app/ui.js
|
@ -1216,11 +1216,10 @@ var UI = {
|
|||
|
||||
var screen = UI.screenSize();
|
||||
|
||||
if (screen && UI.connected && UI.rfb.get_display()) {
|
||||
if (screen && UI.connected) {
|
||||
|
||||
var display = UI.rfb.get_display();
|
||||
var resizeMode = UI.getSetting('resize');
|
||||
display.set_scale(1);
|
||||
UI.rfb.set_scale(1);
|
||||
|
||||
// Make sure the viewport is adjusted first
|
||||
UI.updateViewClip();
|
||||
|
@ -1258,13 +1257,12 @@ var UI = {
|
|||
|
||||
var screen = UI.screenSize();
|
||||
|
||||
if (!screen || !UI.connected || !UI.rfb.get_display()) {
|
||||
if (!screen || !UI.connected) {
|
||||
return;
|
||||
}
|
||||
|
||||
var display = UI.rfb.get_display();
|
||||
var downscaleOnly = resizeMode === 'downscale';
|
||||
display.autoscale(screen.w, screen.h, downscaleOnly);
|
||||
UI.rfb.autoscale(screen.w, screen.h, downscaleOnly);
|
||||
UI.fixScrollbars();
|
||||
},
|
||||
|
||||
|
@ -1302,8 +1300,7 @@ var UI = {
|
|||
updateViewClip: function() {
|
||||
if (!UI.rfb) return;
|
||||
|
||||
var display = UI.rfb.get_display();
|
||||
var cur_clip = display.get_viewport();
|
||||
var cur_clip = UI.rfb.get_viewport();
|
||||
var new_clip = UI.getSetting('view_clip');
|
||||
|
||||
var resizeSetting = UI.getSetting('resize');
|
||||
|
@ -1316,7 +1313,7 @@ var UI = {
|
|||
}
|
||||
|
||||
if (cur_clip !== new_clip) {
|
||||
display.set_viewport(new_clip);
|
||||
UI.rfb.set_viewport(new_clip);
|
||||
}
|
||||
|
||||
var size = UI.screenSize();
|
||||
|
@ -1324,7 +1321,7 @@ var UI = {
|
|||
if (new_clip && size) {
|
||||
// When clipping is enabled, the screen is limited to
|
||||
// the size of the browser window.
|
||||
display.viewportChangeSize(size.w, size.h);
|
||||
UI.rfb.viewportChangeSize(size.w, size.h);
|
||||
UI.fixScrollbars();
|
||||
}
|
||||
|
||||
|
@ -1374,8 +1371,8 @@ var UI = {
|
|||
|
||||
// Check if viewport drag is possible. It is only possible
|
||||
// if the remote display is clipping the client display.
|
||||
if (UI.rfb.get_display().get_viewport() &&
|
||||
UI.rfb.get_display().clippingDisplay()) {
|
||||
if (UI.rfb.get_viewport() &&
|
||||
UI.rfb.clippingDisplay()) {
|
||||
clipping = true;
|
||||
}
|
||||
|
||||
|
|
34
core/rfb.js
34
core/rfb.js
|
@ -338,6 +338,21 @@ RFB.prototype = {
|
|||
RFB.messages.clientCutText(this._sock, text);
|
||||
},
|
||||
|
||||
autoscale: function (width, height, downscaleOnly) {
|
||||
if (this._rfb_connection_state !== 'connected') { return; }
|
||||
this._display.autoscale(width, height, downscaleOnly);
|
||||
},
|
||||
|
||||
viewportChangeSize: function(width, height) {
|
||||
if (this._rfb_connection_state !== 'connected') { return; }
|
||||
this._display.viewportChangeSize(width, height);
|
||||
},
|
||||
|
||||
clippingDisplay: function () {
|
||||
if (this._rfb_connection_state !== 'connected') { return false; }
|
||||
return this._display.clippingDisplay();
|
||||
},
|
||||
|
||||
// Requests a change of remote desktop size. This message is an extension
|
||||
// and may only be sent if we have received an ExtendedDesktopSize message
|
||||
requestDesktopSize: function (width, height) {
|
||||
|
@ -1478,6 +1493,8 @@ make_properties(RFB, [
|
|||
['local_cursor', 'rw', 'bool'], // Request locally rendered cursor
|
||||
['shared', 'rw', 'bool'], // Request shared mode
|
||||
['view_only', 'rw', 'bool'], // Disable client mouse/keyboard
|
||||
['scale', 'rw', 'float'], // Display area scale factor
|
||||
['viewport', 'rw', 'bool'], // Use viewport clipping
|
||||
['xvp_password_sep', 'rw', 'str'], // Separator for XVP password fields
|
||||
['disconnectTimeout', 'rw', 'int'], // Time (s) to wait for disconnection
|
||||
['wsProtocols', 'rw', 'arr'], // Protocols to use in the WebSocket connection
|
||||
|
@ -1532,7 +1549,22 @@ RFB.prototype.set_view_only = function (view_only) {
|
|||
}
|
||||
};
|
||||
|
||||
RFB.prototype.get_display = function () { return this._display; };
|
||||
RFB.prototype.set_scale = function (scale) {
|
||||
this._display.set_scale(scale);
|
||||
};
|
||||
|
||||
RFB.prototype.get_scale = function () {
|
||||
return this._display.get_scale();
|
||||
};
|
||||
|
||||
RFB.prototype.set_viewport = function (viewport) {
|
||||
this._display.set_viewport(viewport);
|
||||
};
|
||||
|
||||
RFB.prototype.get_viewport = function () {
|
||||
return this._display.get_viewport();
|
||||
};
|
||||
|
||||
RFB.prototype.get_keyboard = function () { return this._keyboard; };
|
||||
RFB.prototype.get_mouse = function () { return this._mouse; };
|
||||
|
||||
|
|
55
docs/API.md
55
docs/API.md
|
@ -27,18 +27,20 @@ attribute mode is one of the following:
|
|||
RW - read write
|
||||
WO - write once
|
||||
|
||||
| name | type | mode | default | description
|
||||
| ----------------- | ---- | ---- | ---------- | ------------
|
||||
| target | DOM | WO | null | Canvas element for rendering (passed to Display, Mouse and Keyboard)
|
||||
| encrypt | bool | RW | false | Use TLS/SSL encryption
|
||||
| local_cursor | bool | RW | false | Request locally rendered cursor
|
||||
| shared | bool | RW | true | Request shared VNC mode
|
||||
| view_only | bool | RW | false | Disable client mouse/keyboard
|
||||
| xvp_password_sep | str | RW | '@' | Separator for XVP password fields
|
||||
| disconnectTimeout | int | RW | 3 | Time (in seconds) to wait for disconnection
|
||||
| wsProtocols | arr | RW | ['binary'] | Protocols to use in the WebSocket connection
|
||||
| repeaterID | str | RW | '' | UltraVNC RepeaterID to connect to
|
||||
| viewportDrag | bool | RW | false | Move the viewport on mouse drags
|
||||
| name | type | mode | default | description
|
||||
| ----------------- | ----- | ---- | ---------- | ------------
|
||||
| target | DOM | WO | null | Canvas element for rendering (passed to Display, Mouse and Keyboard)
|
||||
| encrypt | bool | RW | false | Use TLS/SSL encryption
|
||||
| local_cursor | bool | RW | false | Request locally rendered cursor
|
||||
| shared | bool | RW | true | Request shared VNC mode
|
||||
| view_only | bool | RW | false | Disable client mouse/keyboard
|
||||
| scale | float | RW | 1.0 | Display area scale factor
|
||||
| viewport | bool | RW | false | Use viewport clipping
|
||||
| xvp_password_sep | str | RW | '@' | Separator for XVP password fields
|
||||
| disconnectTimeout | int | RW | 3 | Time (in seconds) to wait for disconnection
|
||||
| wsProtocols | arr | RW | ['binary'] | Protocols to use in the WebSocket connection
|
||||
| repeaterID | str | RW | '' | UltraVNC RepeaterID to connect to
|
||||
| viewportDrag | bool | RW | false | Move the viewport on mouse drags
|
||||
|
||||
|
||||
## 2 Methods
|
||||
|
@ -47,19 +49,22 @@ In addition to the getter and setter methods to modify configuration
|
|||
attributes, the RFB object has other methods that are available in the
|
||||
object instance.
|
||||
|
||||
| name | parameters | description
|
||||
| ------------------ | ---------------------------- | ------------
|
||||
| connect | (host, port, password, path) | Connect to the given host:port/path. Optional password and path.
|
||||
| disconnect | () | Disconnect
|
||||
| sendPassword | (passwd) | Send password after onPasswordRequired callback
|
||||
| sendCtrlAltDel | () | Send Ctrl-Alt-Del key sequence
|
||||
| xvpOp | (ver, op) | Send a XVP operation (2=shutdown, 3=reboot, 4=reset)
|
||||
| xvpShutdown | () | Send XVP shutdown.
|
||||
| xvpReboot | () | Send XVP reboot.
|
||||
| xvpReset | () | Send XVP reset.
|
||||
| sendKey | (keysym, code, down) | Send a key press event. If down not specified, send a down and up event.
|
||||
| clipboardPasteFrom | (text) | Send a clipboard paste event
|
||||
| requestDesktopSize | (width, height) | Send a request to change the remote desktop size.
|
||||
| name | parameters | description
|
||||
| ------------------ | ------------------------------ | ------------
|
||||
| connect | (host, port, password, path) | Connect to the given host:port/path. Optional password and path.
|
||||
| disconnect | () | Disconnect
|
||||
| sendPassword | (passwd) | Send password after onPasswordRequired callback
|
||||
| sendCtrlAltDel | () | Send Ctrl-Alt-Del key sequence
|
||||
| xvpOp | (ver, op) | Send a XVP operation (2=shutdown, 3=reboot, 4=reset)
|
||||
| xvpShutdown | () | Send XVP shutdown.
|
||||
| xvpReboot | () | Send XVP reboot.
|
||||
| xvpReset | () | Send XVP reset.
|
||||
| sendKey | (keysym, code, down) | Send a key press event. If down not specified, send a down and up event.
|
||||
| clipboardPasteFrom | (text) | Send a clipboard paste event
|
||||
| autoscale | (width, height, downscaleOnly) | Scale the display
|
||||
| clippingDisplay | () | Check if the remote display is larger than the client display
|
||||
| requestDesktopSize | (width, height) | Send a request to change the remote desktop size.
|
||||
| viewportChangeSize | (width, height) | Change size of the viewport
|
||||
|
||||
|
||||
## 3 Callbacks
|
||||
|
|
Loading…
Reference in New Issue