Limit MouseMove Messages to once per 100mS

This commit is contained in:
Uwe Klatt 2019-12-19 09:08:11 +01:00 committed by GitHub
parent 84a8c1b0cc
commit 246d7cc774
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -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);
}