From 0ccf432f12e57ecee858ec68ca23a01e41498829 Mon Sep 17 00:00:00 2001 From: Samuel Mannehed Date: Tue, 30 Aug 2016 09:27:32 +0200 Subject: View-only mode doesn't need keyboard or mouse Grabbing the keyboard and mouse is unnecessary in view_only mode. In fact its unnecessary to create the objects at all. Fixes #644. --- include/rfb.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/rfb.js b/include/rfb.js index 9935962..55313ac 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -184,13 +184,15 @@ var RFB; throw exc; } - this._keyboard = new Keyboard({target: this._focusContainer, - onKeyPress: this._handleKeyPress.bind(this)}); - - this._mouse = new Mouse({target: this._target, - onMouseButton: this._handleMouseButton.bind(this), - onMouseMove: this._handleMouseMove.bind(this), - notify: this._keyboard.sync.bind(this._keyboard)}); + if (!this._view_only) { + this._keyboard = new Keyboard({target: this._focusContainer, + onKeyPress: this._handleKeyPress.bind(this)}); + + this._mouse = new Mouse({target: this._target, + onMouseButton: this._handleMouseButton.bind(this), + onMouseMove: this._handleMouseMove.bind(this), + notify: this._keyboard.sync.bind(this._keyboard)}); + } this._sock = new Websock(); this._sock.on('message', this._handle_message.bind(this)); -- cgit v1.2.1