Merge branch 'settingswhileconnected' of https://github.com/samhed/noVNC

Closes pull request #778
This commit is contained in:
Samuel Mannehed 2017-02-24 15:42:27 +01:00
commit b56d975248
2 changed files with 47 additions and 14 deletions

View File

@ -440,12 +440,15 @@ var UI;
UI.addSettingChangeHandler('encrypt');
UI.addSettingChangeHandler('true_color');
UI.addSettingChangeHandler('cursor');
UI.addSettingChangeHandler('cursor', UI.updateLocalCursor);
UI.addSettingChangeHandler('resize');
UI.addSettingChangeHandler('resize', UI.enableDisableViewClip);
UI.addSettingChangeHandler('resize', UI.applyResizeMode);
UI.addSettingChangeHandler('clip');
UI.addSettingChangeHandler('clip', UI.updateViewClip);
UI.addSettingChangeHandler('shared');
UI.addSettingChangeHandler('view_only');
UI.addSettingChangeHandler('view_only', UI.updateViewOnly);
UI.addSettingChangeHandler('host');
UI.addSettingChangeHandler('port');
UI.addSettingChangeHandler('path');
@ -520,18 +523,20 @@ var UI;
UI.enableDisableViewClip();
if (Util.browserSupportsCursorURIs() && !Util.isTouchDevice) {
UI.enableSetting('cursor');
} else {
UI.disableSetting('cursor');
}
if (UI.connected) {
UI.disableSetting('encrypt');
UI.disableSetting('true_color');
UI.disableSetting('cursor');
UI.disableSetting('shared');
UI.disableSetting('view_only');
UI.disableSetting('host');
UI.disableSetting('port');
UI.disableSetting('path');
UI.disableSetting('repeaterID');
UI.disableSetting('reconnect');
UI.disableSetting('reconnect_delay');
UI.updateViewClip();
UI.setMouseButton(1);
@ -540,17 +545,11 @@ var UI;
} else {
UI.enableSetting('encrypt');
UI.enableSetting('true_color');
if (Util.browserSupportsCursorURIs() && !Util.isTouchDevice) {
UI.enableSetting('cursor');
}
UI.enableSetting('shared');
UI.enableSetting('view_only');
UI.enableSetting('host');
UI.enableSetting('port');
UI.enableSetting('path');
UI.enableSetting('repeaterID');
UI.enableSetting('reconnect');
UI.enableSetting('reconnect_delay');
UI.updateXvpButton(0);
UI.keepControlbar();
}
@ -1108,11 +1107,12 @@ var UI;
UI.rfb.set_encrypt(UI.getSetting('encrypt'));
UI.rfb.set_true_color(UI.getSetting('true_color'));
UI.rfb.set_local_cursor(UI.getSetting('cursor'));
UI.rfb.set_shared(UI.getSetting('shared'));
UI.rfb.set_view_only(UI.getSetting('view_only'));
UI.rfb.set_repeaterID(UI.getSetting('repeaterID'));
UI.updateLocalCursor();
UI.updateViewOnly();
UI.rfb.connect(host, port, password, path);
},
@ -1362,7 +1362,7 @@ var UI;
var resizeSetting = UI.getSetting('resize');
// Disable clipping if we are scaling, connected or on touch
if (resizeSetting === 'downscale' || resizeSetting === 'scale' ||
UI.connected || Util.isTouchDevice) {
Util.isTouchDevice) {
UI.disableSetting('clip');
} else {
UI.enableSetting('clip');
@ -1700,6 +1700,14 @@ var UI;
}
},
updateLocalCursor: function() {
UI.rfb.set_local_cursor(UI.getSetting('cursor'));
},
updateViewOnly: function() {
UI.rfb.set_view_only(UI.getSetting('view_only'));
},
updateLogging: function() {
WebUtil.init_logging(UI.getSetting('logging'));
},

View File

@ -343,7 +343,9 @@
},
clipboardPasteFrom: function (text) {
if (this._rfb_connection_state !== 'connected') { return; }
if (this._rfb_connection_state !== 'connected' || this._view_only) {
return;
}
RFB.messages.clientCutText(this._sock, text);
},
@ -1189,6 +1191,8 @@
_handle_server_cut_text: function () {
Util.Debug("ServerCutText");
if (this._view_only) { return true; }
if (this._sock.rQwait("ServerCutText header", 7, 1)) { return false; }
this._sock.rQskipBytes(3); // Padding
var length = this._sock.rQshift32();
@ -1486,6 +1490,27 @@
this._display.disableLocalCursor();
}
}
// Need to send an updated list of encodings if we are connected
if (this._rfb_connection_state === "connected") {
RFB.messages.clientEncodings(this._sock, this._encodings, cursor,
this._true_color);
}
};
RFB.prototype.set_view_only = function (view_only) {
this._view_only = view_only;
if (this._rfb_connection_state === "connecting" ||
this._rfb_connection_state === "connected") {
if (view_only) {
this._keyboard.ungrab();
this._mouse.ungrab();
} else {
this._keyboard.grab();
this._mouse.grab();
}
}
};
RFB.prototype.get_display = function () { return this._display; };