Browse Source

Adds tap-to-click in viewport drag mode (#600)

Jonathan Bennett 9 years ago
parent
commit
27e77d468f
1 changed files with 13 additions and 0 deletions
  1. 13 0
      include/rfb.js

+ 13 - 0
include/rfb.js

@@ -119,6 +119,7 @@ var RFB;
         this._mouse_arr = [];
         this._mouse_arr = [];
         this._viewportDragging = false;
         this._viewportDragging = false;
         this._viewportDragPos = {};
         this._viewportDragPos = {};
+        this._viewportHasMoved = false;
 
 
         // set the default value on user-facing properties
         // set the default value on user-facing properties
         Util.set_defaults(this, defaults, {
         Util.set_defaults(this, defaults, {
@@ -593,6 +594,13 @@ var RFB;
                     return;
                     return;
                 } else {
                 } else {
                     this._viewportDragging = false;
                     this._viewportDragging = false;
+
+                    // If the viewport didn't actually move, then treat as a mouse click event
+                    // Send the button down event here, as the button up event is sent at the end of this function
+                    if (!this._viewportHasMoved && !this._view_only) {
+                        RFB.messages.pointerEvent(this._sock, this._display.absX(x), this._display.absY(y), bmask);
+                    }
+                    this._viewportHasMoved = false;
                 }
                 }
             }
             }
 
 
@@ -608,6 +616,11 @@ var RFB;
                 var deltaY = this._viewportDragPos.y - y;
                 var deltaY = this._viewportDragPos.y - y;
                 this._viewportDragPos = {'x': x, '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;
+                 }
+
                 this._display.viewportChangePos(deltaX, deltaY);
                 this._display.viewportChangePos(deltaX, deltaY);
 
 
                 // Skip sending mouse events
                 // Skip sending mouse events