Lines 1-6
Link Here
|
1 |
/* |
1 |
/* |
2 |
* noVNC: HTML5 VNC client |
2 |
* noVNC: HTML5 VNC client |
3 |
* Copyright (C) 2012 Joel Martin |
3 |
* Copyright (C) 2012 Joel Martin |
|
|
4 |
* Copyright (C) 2013 Samuel Mannehed for Cendio AB |
4 |
* Licensed under MPL 2.0 or any later version (see LICENSE.txt) |
5 |
* Licensed under MPL 2.0 or any later version (see LICENSE.txt) |
5 |
*/ |
6 |
*/ |
6 |
|
7 |
|
Lines 489-494
var that = {}, // Public API methods
Link Here
|
489 |
conf = {}, // Configuration attributes |
490 |
conf = {}, // Configuration attributes |
490 |
mouseCaptured = false; |
491 |
mouseCaptured = false; |
491 |
|
492 |
|
|
|
493 |
var doubleClickTimer = null, |
494 |
lastClickPos = null; |
495 |
|
492 |
// Configuration attributes |
496 |
// Configuration attributes |
493 |
Util.conf_defaults(conf, that, defaults, [ |
497 |
Util.conf_defaults(conf, that, defaults, [ |
494 |
['target', 'ro', 'dom', document, 'DOM element that captures mouse input'], |
498 |
['target', 'ro', 'dom', document, 'DOM element that captures mouse input'], |
Lines 521-526
function releaseMouse() {
Link Here
|
521 |
// Private functions |
525 |
// Private functions |
522 |
// |
526 |
// |
523 |
|
527 |
|
|
|
528 |
function resetDoubleClickTimer() { |
529 |
doubleClickTimer = null; |
530 |
} |
531 |
|
524 |
function onMouseButton(e, down) { |
532 |
function onMouseButton(e, down) { |
525 |
var evt, pos, bmask; |
533 |
var evt, pos, bmask; |
526 |
if (! conf.focused) { |
534 |
if (! conf.focused) { |
Lines 528-533
function onMouseButton(e, down) {
Link Here
|
528 |
} |
536 |
} |
529 |
evt = (e ? e : window.event); |
537 |
evt = (e ? e : window.event); |
530 |
pos = Util.getEventPosition(e, conf.target, conf.scale); |
538 |
pos = Util.getEventPosition(e, conf.target, conf.scale); |
|
|
539 |
|
540 |
// When two clicks occur within 500 ms of each other and are |
541 |
// closer than 50 pixels together a double click is triggered. |
542 |
if (down == 1) { |
543 |
if (doubleClickTimer == null) { |
544 |
lastClickPos = pos; |
545 |
} else { |
546 |
clearTimeout(doubleClickTimer); |
547 |
|
548 |
var xs = lastClickPos.x - pos.x; |
549 |
var ys = lastClickPos.y - pos.y; |
550 |
var d = Math.sqrt((xs * xs) + (ys * ys)); |
551 |
|
552 |
// When the distance between the two clicks is less than 50 pixels |
553 |
// force the position of the latter click to the position of the first |
554 |
if (d < 50) { |
555 |
pos = lastClickPos; |
556 |
} |
557 |
} |
558 |
doubleClickTimer = setTimeout(resetDoubleClickTimer, 500); |
559 |
} |
560 |
|
531 |
if (e.touches || e.changedTouches) { |
561 |
if (e.touches || e.changedTouches) { |
532 |
// Touch device |
562 |
// Touch device |
533 |
bmask = conf.touchButton; |
563 |
bmask = conf.touchButton; |