From 483f3df7896ca8650d27254a89079172b5fac7cf Mon Sep 17 00:00:00 2001 From: Juanjo Diaz Date: Thu, 16 Jan 2020 15:22:25 +0200 Subject: [PATCH] Fix errors on non-touch devices --- app/ui.js | 16 ++++++++++------ core/rfb.js | 10 ++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/ui.js b/app/ui.js index 61ddffe0..5ea4dc1d 100644 --- a/app/ui.js +++ b/app/ui.js @@ -88,7 +88,7 @@ const UI = { // Setup event handlers UI.addControlbarHandlers(); - UI.addTouchSpecificHandlers(); + if (isTouchDevice) { UI.addTouchSpecificHandlers(); } UI.addExtraKeysHandlers(); UI.addMachineHandlers(); UI.addConnectionControlHandlers(); @@ -430,7 +430,7 @@ const UI = { UI.disableSetting('port'); UI.disableSetting('path'); UI.disableSetting('repeaterID'); - UI.setMouseButton(1); + if (isTouchDevice) { UI.setMouseButton(1); } // Hide the controlbar after 2 seconds UI.closeControlbarTimeout = setTimeout(UI.closeControlbar, 2000); @@ -1661,8 +1661,10 @@ const UI = { .classList.add('noVNC_hidden'); document.getElementById('noVNC_toggle_extra_keys_button') .classList.add('noVNC_hidden'); - document.getElementById('noVNC_mouse_button' + UI.rfb.touchButton) - .classList.add('noVNC_hidden'); + if (isTouchDevice) { + document.getElementById('noVNC_mouse_button' + UI.rfb.touchButton) + .classList.add('noVNC_hidden'); + } document.getElementById('noVNC_clipboard_button') .classList.add('noVNC_hidden'); } else { @@ -1670,8 +1672,10 @@ const UI = { .classList.remove('noVNC_hidden'); document.getElementById('noVNC_toggle_extra_keys_button') .classList.remove('noVNC_hidden'); - document.getElementById('noVNC_mouse_button' + UI.rfb.touchButton) - .classList.remove('noVNC_hidden'); + if (isTouchDevice) { + document.getElementById('noVNC_mouse_button' + UI.rfb.touchButton) + .classList.remove('noVNC_hidden'); + } document.getElementById('noVNC_clipboard_button') .classList.remove('noVNC_hidden'); } diff --git a/core/rfb.js b/core/rfb.js index fc8e4579..1c38460a 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -311,8 +311,14 @@ export default class RFB extends EventTargetMixin { get capabilities() { return this._capabilities; } - get touchButton() { return this._touch.touchButton; } - set touchButton(button) { this._touch.touchButton = button; } + get touchButton() { + if (!this._touch) { return null; } + return this._touch.touchButton; + } + set touchButton(button) { + if (!this._touch) { return; } + this._touch.touchButton = button; + } get clipViewport() { return this._clipViewport; } set clipViewport(viewport) {