From 246d7cc7746e6d7f7300032d967460a0db0015fa Mon Sep 17 00:00:00 2001 From: Uwe Klatt <42005666+uklatt@users.noreply.github.com> Date: Thu, 19 Dec 2019 09:08:11 +0100 Subject: [PATCH] Limit MouseMove Messages to once per 100mS --- core/rfb.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/rfb.js b/core/rfb.js index e5849605..c167f159 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -776,6 +776,10 @@ export default class RFB extends EventTargetMixin { const deltaX = this._viewportDragPos.x - x; const deltaY = this._viewportDragPos.y - y; + if( typeof _handleMouseMove.timestamp == 'undefined' ) { + _handleMouseMove.oldtimestamp = Date.now(); + } + if (this._viewportHasMoved || (Math.abs(deltaX) > dragThreshold || Math.abs(deltaY) > dragThreshold)) { this._viewportHasMoved = true; @@ -790,6 +794,10 @@ export default class RFB extends EventTargetMixin { if (this._viewOnly) { return; } // View only, skip mouse events + this.timestamp = Date.now(); + if(this.timestamp < this.oldtimestamp + 100) { return; } + this.oldtimestamp = this.timestamp; + if (this._rfb_connection_state !== 'connected') { return; } RFB.messages.pointerEvent(this._sock, this._display.absX(x), this._display.absY(y), this._mouse_buttonMask); }