summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsamhed <samuel@cendio.se>2016-04-28 17:41:48 +0200
committersamhed <samuel@cendio.se>2016-04-28 17:41:48 +0200
commit32df3fdbe1b289b06344902b72537d6dc3671afb (patch)
treebd2c33f747b37cd3e2447486cebd292a990b931e
parent27e77d468f041e91c717be37d48242d392e2a81a (diff)
downloadnovnc-32df3fdbe1b289b06344902b72537d6dc3671afb.tar.gz
Add a threshold for viewport dragging (#600)
-rw-r--r--include/rfb.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/include/rfb.js b/include/rfb.js
index e409217..3e9344b 100644
--- a/include/rfb.js
+++ b/include/rfb.js
@@ -614,14 +614,18 @@ var RFB;
if (this._viewportDragging) {
var deltaX = this._viewportDragPos.x - x;
var deltaY = this._viewportDragPos.y - y;
- this._viewportDragPos = {'x': x, 'y': y};
- // if there is actually viewport move, set the HasMoved flag to true
- if (deltaX != 0 || deltaY != 0) {
- this._viewportHasMoved = true;
- }
+ // The goal is to trigger on a certain physical width, the
+ // devicePixelRatio brings us a bit closer but is not optimal.
+ var dragThreshold = 10 * window.devicePixelRatio;
- this._display.viewportChangePos(deltaX, deltaY);
+ if (this._viewportHasMoved || (Math.abs(deltaX) > dragThreshold ||
+ Math.abs(deltaY) > dragThreshold)) {
+ this._viewportHasMoved = true;
+
+ this._viewportDragPos = {'x': x, 'y': y};
+ this._display.viewportChangePos(deltaX, deltaY);
+ }
// Skip sending mouse events
return;