From 7696ac713c3ad77274ad3ddf1859435f6b8dbab6 Mon Sep 17 00:00:00 2001 From: Samuel Mannehed Date: Fri, 1 Sep 2017 13:59:10 +0200 Subject: [PATCH 1/3] Remove unused variable --- app/ui.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/ui.js b/app/ui.js index 1b360438..ff403b05 100644 --- a/app/ui.js +++ b/app/ui.js @@ -38,7 +38,6 @@ var UI = { controlbarMouseDownOffsetY: 0, isSafari: false, - rememberedClipSetting: null, lastKeyboardinput: null, defaultKeyboardinputLen: 100, From 6a1152e6b4e1d2cff797279de787785ee417b2b2 Mon Sep 17 00:00:00 2001 From: Samuel Mannehed Date: Fri, 1 Sep 2017 14:52:26 +0200 Subject: [PATCH 2/3] Rename setting_clip to setting_view_clip Clarifies the purpose of the setting in order to avoid mix ups with clipboard related things. --- app/ui.js | 26 +++++++++++++------------- vnc.html | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/ui.js b/app/ui.js index ff403b05..de7a9a27 100644 --- a/app/ui.js +++ b/app/ui.js @@ -171,7 +171,7 @@ var UI = { UI.initSetting('port', port); UI.initSetting('encrypt', (window.location.protocol === "https:")); UI.initSetting('cursor', !isTouchDevice); - UI.initSetting('clip', false); + UI.initSetting('view_clip', false); UI.initSetting('resize', 'off'); UI.initSetting('shared', true); UI.initSetting('view_only', false); @@ -386,8 +386,8 @@ var UI = { UI.addSettingChangeHandler('resize'); UI.addSettingChangeHandler('resize', UI.enableDisableViewClip); UI.addSettingChangeHandler('resize', UI.applyResizeMode); - UI.addSettingChangeHandler('clip'); - UI.addSettingChangeHandler('clip', UI.updateViewClip); + UI.addSettingChangeHandler('view_clip'); + UI.addSettingChangeHandler('view_clip', UI.updateViewClip); UI.addSettingChangeHandler('shared'); UI.addSettingChangeHandler('view_only'); UI.addSettingChangeHandler('view_only', UI.updateViewOnly); @@ -892,7 +892,7 @@ var UI = { UI.updateSetting('cursor', !isTouchDevice); UI.disableSetting('cursor'); } - UI.updateSetting('clip'); + UI.updateSetting('view_clip'); UI.updateSetting('resize'); UI.updateSetting('shared'); UI.updateSetting('view_only'); @@ -1289,26 +1289,26 @@ var UI = { /* ------^------- * /RESIZE * ============== - * CLIPPING + * VIEW CLIPPING * ------v------*/ // Set and configure viewport clipping setViewClip: function(clip) { - UI.updateSetting('clip', clip); + UI.updateSetting('view_clip', clip); UI.updateViewClip(); }, - // Update parameters that depend on the clip setting + // Update parameters that depend on the viewport clip setting updateViewClip: function() { if (!UI.rfb) return; var display = UI.rfb.get_display(); var cur_clip = display.get_viewport(); - var new_clip = UI.getSetting('clip'); + var new_clip = UI.getSetting('view_clip'); var resizeSetting = UI.getSetting('resize'); if (resizeSetting === 'downscale' || resizeSetting === 'scale') { - // Disable clipping if we are scaling + // Disable viewport clipping if we are scaling new_clip = false; } else if (isTouchDevice) { // Touch devices usually have shit scrollbars @@ -1333,20 +1333,20 @@ var UI = { UI.updateViewDrag(); }, - // Handle special cases where clipping is forced on/off or locked + // Handle special cases where viewport clipping is forced on/off or locked enableDisableViewClip: function() { var resizeSetting = UI.getSetting('resize'); // Disable clipping if we are scaling, connected or on touch if (resizeSetting === 'downscale' || resizeSetting === 'scale' || isTouchDevice) { - UI.disableSetting('clip'); + UI.disableSetting('view_clip'); } else { - UI.enableSetting('clip'); + UI.enableSetting('view_clip'); } }, /* ------^------- - * /CLIPPING + * /VIEW CLIPPING * ============== * VIEWDRAG * ------v------*/ diff --git a/vnc.html b/vnc.html index 0109ce69..7845fa66 100644 --- a/vnc.html +++ b/vnc.html @@ -206,7 +206,7 @@

  • - +
  • From 40654f258622e504e2acb2ad7df5dab5f2983650 Mon Sep 17 00:00:00 2001 From: Samuel Mannehed Date: Fri, 1 Sep 2017 16:30:27 +0200 Subject: [PATCH 3/3] Add setting for clipboard --- app/ui.js | 22 ++++++++++++++++++++++ core/rfb.js | 11 +++++++++-- vnc.html | 3 +++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/app/ui.js b/app/ui.js index de7a9a27..9a5b1958 100644 --- a/app/ui.js +++ b/app/ui.js @@ -383,6 +383,8 @@ var UI = { UI.addSettingChangeHandler('encrypt'); UI.addSettingChangeHandler('cursor'); UI.addSettingChangeHandler('cursor', UI.updateLocalCursor); + UI.addSettingChangeHandler('clipboard'); + UI.addSettingChangeHandler('clipboard', UI.updateClipboard); UI.addSettingChangeHandler('resize'); UI.addSettingChangeHandler('resize', UI.enableDisableViewClip); UI.addSettingChangeHandler('resize', UI.applyResizeMode); @@ -1002,23 +1004,43 @@ var UI = { }, clipboardReceive: function(rfb, text) { + if (!UI.getSetting('clipboard')) return; + Log.Debug(">> UI.clipboardReceive: " + text.substr(0,40) + "..."); document.getElementById('noVNC_clipboard_text').value = text; Log.Debug("<< UI.clipboardReceive"); }, clipboardClear: function() { + if (!UI.getSetting('clipboard')) return; + document.getElementById('noVNC_clipboard_text').value = ""; UI.rfb.clipboardPasteFrom(""); }, clipboardSend: function() { + if (!UI.getSetting('clipboard')) return; + var text = document.getElementById('noVNC_clipboard_text').value; Log.Debug(">> UI.clipboardSend: " + text.substr(0,40) + "..."); UI.rfb.clipboardPasteFrom(text); Log.Debug("<< UI.clipboardSend"); }, + updateClipboard: function() { + if (!UI.rfb) return; + + var clipboard_enabled = UI.getSetting('clipboard'); + var clipboard_button = document.getElementById('noVNC_clipboard_button'); + if (clipboard_enabled) { + clipboard_button.disabled = false; + UI.rfb.set_clipboard(true); + } else { + clipboard_button.disabled = true; + UI.rfb.set_clipboard(false); + } + }, + /* ------^------- * /CLIPBOARD * ============== diff --git a/core/rfb.js b/core/rfb.js index ece0f008..8b3c6aeb 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -151,6 +151,7 @@ export default function RFB(defaults) { 'encrypt': false, // Use TLS/SSL/wss encryption 'local_cursor': false, // Request locally rendered cursor 'shared': true, // Request shared mode + 'clipboard': true, // Synchronize server and client clipboard contents 'view_only': false, // Disable client mouse/keyboard 'xvp_password_sep': '@', // Separator for XVP password fields 'disconnectTimeout': 3, // Time (s) to wait for disconnection @@ -356,7 +357,12 @@ RFB.prototype = { }, clipboardPasteFrom: function (text) { - if (this._rfb_connection_state !== 'connected' || this._view_only) { return; } + if (this._rfb_connection_state !== 'connected' || + this._view_only || + !this._clipboard) { + + return; + } RFB.messages.clientCutText(this._sock, text); }, @@ -1167,7 +1173,7 @@ RFB.prototype = { var text = this._sock.rQshiftStr(length); - if (this._view_only) { return true; } + if (this._view_only || !this._clipboard) { return true; } this._onClipboard(this, text); @@ -1426,6 +1432,7 @@ make_properties(RFB, [ ['encrypt', 'rw', 'bool'], // Use TLS/SSL/wss encryption ['local_cursor', 'rw', 'bool'], // Request locally rendered cursor ['shared', 'rw', 'bool'], // Request shared mode + ['clipboard', 'rw', 'bool'], // Synchronize server and client clipboard contents ['view_only', 'rw', 'bool'], // Disable client mouse/keyboard ['xvp_password_sep', 'rw', 'str'], // Separator for XVP password fields ['disconnectTimeout', 'rw', 'int'], // Time (s) to wait for disconnection diff --git a/vnc.html b/vnc.html index 7845fa66..4b35de64 100644 --- a/vnc.html +++ b/vnc.html @@ -204,6 +204,9 @@
  • +
  • + +