From 88589a44f7ff8bdcb9f66bc9160e83a6f0827bb5 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 10 Jun 2020 14:12:22 +0200 Subject: [PATCH] Increase wheel step threshold The previous value made the detection too sensitive and it was very difficult to scroll precisely. A value of 50 pixels should give similar behaviour to systems that don't do fine grained scrolling. --- core/rfb.js | 6 +++--- tests/test.rfb.js | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/rfb.js b/core/rfb.js index 4d1dcf1e..c5b60160 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -42,7 +42,7 @@ const DEFAULT_BACKGROUND = 'rgb(40, 40, 40)'; const MOUSE_MOVE_DELAY = 17; // Wheel thresholds -const WHEEL_STEP = 10; // Pixels needed for one step +const WHEEL_STEP = 50; // Pixels needed for one step const WHEEL_LINE_HEIGHT = 19; // Assumed pixels for one line step // Gesture thresholds @@ -981,7 +981,7 @@ export default class RFB extends EventTargetMixin { // Generate a mouse wheel step event when the accumulated delta // for one of the axes is large enough. - if (Math.abs(this._accumulatedWheelDeltaX) > WHEEL_STEP) { + if (Math.abs(this._accumulatedWheelDeltaX) >= WHEEL_STEP) { if (this._accumulatedWheelDeltaX < 0) { this._handleMouseButton(pos.x, pos.y, true, 1 << 5); this._handleMouseButton(pos.x, pos.y, false, 1 << 5); @@ -992,7 +992,7 @@ export default class RFB extends EventTargetMixin { this._accumulatedWheelDeltaX = 0; } - if (Math.abs(this._accumulatedWheelDeltaY) > WHEEL_STEP) { + if (Math.abs(this._accumulatedWheelDeltaY) >= WHEEL_STEP) { if (this._accumulatedWheelDeltaY < 0) { this._handleMouseButton(pos.x, pos.y, true, 1 << 3); this._handleMouseButton(pos.x, pos.y, false, 1 << 3); diff --git a/tests/test.rfb.js b/tests/test.rfb.js index 909b300a..cc450cd9 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -2978,12 +2978,12 @@ describe('Remote Frame Buffer Protocol Client', function () { }); it('should accumulate wheel events if small enough', function () { - sendWheelEvent(10, 10, 0, 4); - sendWheelEvent(10, 10, 0, 4); + sendWheelEvent(10, 10, 0, 20); + sendWheelEvent(10, 10, 0, 20); expect(pointerEvent).to.not.have.been.called; - sendWheelEvent(10, 10, 0, 4); + sendWheelEvent(10, 10, 0, 20); expect(pointerEvent).to.have.been.calledTwice; expect(pointerEvent.firstCall).to.have.been.calledWith(client._sock, @@ -3003,7 +3003,7 @@ describe('Remote Frame Buffer Protocol Client', function () { }); it('should handle line based wheel event', function () { - sendWheelEvent(10, 10, 0, 1, 1); + sendWheelEvent(10, 10, 0, 3, 1); expect(pointerEvent).to.have.been.calledTwice; expect(pointerEvent.firstCall).to.have.been.calledWith(client._sock, @@ -3013,7 +3013,7 @@ describe('Remote Frame Buffer Protocol Client', function () { }); it('should handle page based wheel event', function () { - sendWheelEvent(10, 10, 0, 1, 2); + sendWheelEvent(10, 10, 0, 3, 2); expect(pointerEvent).to.have.been.calledTwice; expect(pointerEvent.firstCall).to.have.been.calledWith(client._sock,