Skip to content

Commit

Permalink
Merge pull request novnc#269 from phildriscoll/master
Browse files Browse the repository at this point in the history
Fix to onMouseDisable
  • Loading branch information
kanaka committed Jul 31, 2013
2 parents f3ff971 + ca9a996 commit 292f6a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions include/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,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;
Expand Down
8 changes: 5 additions & 3 deletions include/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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};
};


Expand Down

0 comments on commit 292f6a5

Please sign in to comment.