From ca9a9964a053f6cbb3f66a536941905858b146fd Mon Sep 17 00:00:00 2001 From: Phil Driscoll Date: Thu, 13 Jun 2013 11:10:04 +0100 Subject: [PATCH 1/2] Fix onMouseDisable so that clicks outside the canvas are propagated --- include/input.js | 6 +++--- include/util.js | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/input.js b/include/input.js index b996c7d5..3b2443a0 100644 --- a/include/input.js +++ b/include/input.js @@ -611,9 +611,9 @@ function onMouseDisable(e) { evt = (e ? e : window.event); pos = Util.getEventPosition(e, conf.target, conf.scale); /* Stop propagation if inside canvas area */ - if ((pos.x >= 0) && (pos.y >= 0) && - (pos.x < conf.target.offsetWidth) && - (pos.y < conf.target.offsetHeight)) { + if ((pos.realx >= 0) && (pos.realy >= 0) && + (pos.realx < conf.target.offsetWidth) && + (pos.realy < conf.target.offsetHeight)) { //Util.Debug("mouse event disabled"); Util.stopEvent(e); return false; diff --git a/include/util.js b/include/util.js index dd1f252f..8893591c 100644 --- a/include/util.js +++ b/include/util.js @@ -298,9 +298,11 @@ Util.getEventPosition = function (e, obj, scale) { if (typeof scale === "undefined") { scale = 1; } - var x = Math.max(Math.min(docX - pos.x, obj.width-1), 0); - var y = Math.max(Math.min(docY - pos.y, obj.height-1), 0); - return {'x': x / scale, 'y': y / scale}; + var realx = docX - pos.x; + var realy = docY - pos.y; + var x = Math.max(Math.min(realx, obj.width-1), 0); + var y = Math.max(Math.min(realy, obj.height-1), 0); + return {'x': x / scale, 'y': y / scale, 'realx': realx / scale, 'realy': realy / scale}; }; From c39df031d865c9abbd8d9e394f4116dc161285da Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Fri, 2 Aug 2013 09:56:15 +0200 Subject: [PATCH 2/2] clearTimeout instead of clearInterval for timers We create timeouts, not intervals. Then we need to clear them with clearTimeout. --- include/rfb.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/rfb.js b/include/rfb.js index 16ae76d5..5258f09d 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -403,7 +403,7 @@ updateState = function(state, statusMsg) { } if (msgTimer) { - clearInterval(msgTimer); + clearTimeout(msgTimer); msgTimer = null; } @@ -444,13 +444,13 @@ updateState = function(state, statusMsg) { if (connTimer && (rfb_state !== 'connect')) { Util.Debug("Clearing connect timer"); - clearInterval(connTimer); + clearTimeout(connTimer); connTimer = null; } if (disconnTimer && (rfb_state !== 'disconnect')) { Util.Debug("Clearing disconnect timer"); - clearInterval(disconnTimer); + clearTimeout(disconnTimer); disconnTimer = null; }