summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Expósito <jose.exposito89@gmail.com>2021-09-26 18:39:32 +0200
committerJosé Expósito <jose.exposito89@gmail.com>2021-11-08 18:00:46 +0100
commit5f0d191eba004277fb258bfde4065040e43853af (patch)
treed02b7f37040498f8a2d3c1db1ccf47d86ef93632
parent4e52f0358056aaaee269a98c0f8bdb7e30c6342e (diff)
downloadlibinput-5f0d191eba004277fb258bfde4065040e43853af.tar.gz
wheel: refactor wheel scroll flushing
Move the logic to flush wheel scroll to it's own funtion. Refactor, no functional changes. Signed-off-by: José Expósito <jose.exposito89@gmail.com>
-rw-r--r--src/evdev-wheel.c156
1 files changed, 82 insertions, 74 deletions
diff --git a/src/evdev-wheel.c b/src/evdev-wheel.c
index 5cbaf3b9..244e4eb0 100644
--- a/src/evdev-wheel.c
+++ b/src/evdev-wheel.c
@@ -30,6 +30,87 @@
#include "evdev-fallback.h"
#include "util-input-event.h"
+static void
+wheel_flush_scroll(struct fallback_dispatch *dispatch,
+ struct evdev_device *device,
+ uint64_t time)
+{
+ struct normalized_coords wheel_degrees = { 0.0, 0.0 };
+ struct discrete_coords discrete = { 0.0, 0.0 };
+ struct wheel_v120 v120 = { 0.0, 0.0 };
+
+ if (device->model_flags & EVDEV_MODEL_LENOVO_SCROLLPOINT) {
+ struct normalized_coords unaccel = { 0.0, 0.0 };
+
+ dispatch->wheel.hi_res.y *= -1;
+ fallback_normalize_delta(device, &dispatch->wheel.hi_res, &unaccel);
+ evdev_post_scroll(device,
+ time,
+ LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
+ &unaccel);
+ dispatch->wheel.hi_res.x = 0;
+ dispatch->wheel.hi_res.y = 0;
+
+ return;
+ }
+
+ if (dispatch->wheel.hi_res.y != 0) {
+ int value = dispatch->wheel.hi_res.y;
+
+ v120.y = -1 * value;
+ wheel_degrees.y = -1 * value/120.0 * device->scroll.wheel_click_angle.y;
+ evdev_notify_axis_wheel(
+ device,
+ time,
+ bit(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL),
+ &wheel_degrees,
+ &v120);
+ dispatch->wheel.hi_res.y = 0;
+ }
+
+ if (dispatch->wheel.lo_res.y != 0) {
+ int value = dispatch->wheel.lo_res.y;
+
+ wheel_degrees.y = -1 * value * device->scroll.wheel_click_angle.y;
+ discrete.y = -1 * value;
+ evdev_notify_axis_legacy_wheel(
+ device,
+ time,
+ bit(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL),
+ &wheel_degrees,
+ &discrete);
+ dispatch->wheel.lo_res.y = 0;
+ }
+
+ if (dispatch->wheel.hi_res.x != 0) {
+ int value = dispatch->wheel.hi_res.x;
+
+ v120.x = value;
+ wheel_degrees.x = value/120.0 * device->scroll.wheel_click_angle.x;
+ evdev_notify_axis_wheel(
+ device,
+ time,
+ bit(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL),
+ &wheel_degrees,
+ &v120);
+ dispatch->wheel.hi_res.x = 0;
+ }
+
+ if (dispatch->wheel.lo_res.x != 0) {
+ int value = dispatch->wheel.lo_res.x;
+
+ wheel_degrees.x = value * device->scroll.wheel_click_angle.x;
+ discrete.x = value;
+ evdev_notify_axis_legacy_wheel(
+ device,
+ time,
+ bit(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL),
+ &wheel_degrees,
+ &discrete);
+ dispatch->wheel.lo_res.x = 0;
+ }
+}
+
void
fallback_wheel_process_relative(struct fallback_dispatch *dispatch,
struct evdev_device *device,
@@ -86,10 +167,6 @@ fallback_wheel_handle_state(struct fallback_dispatch *dispatch,
struct evdev_device *device,
uint64_t time)
{
- struct normalized_coords wheel_degrees = { 0.0, 0.0 };
- struct discrete_coords discrete = { 0.0, 0.0 };
- struct wheel_v120 v120 = { 0.0, 0.0 };
-
if (!(device->seat_caps & EVDEV_DEVICE_POINTER))
return;
@@ -113,76 +190,7 @@ fallback_wheel_handle_state(struct fallback_dispatch *dispatch,
return;
}
- if (device->model_flags & EVDEV_MODEL_LENOVO_SCROLLPOINT) {
- struct normalized_coords unaccel = { 0.0, 0.0 };
-
- dispatch->wheel.hi_res.y *= -1;
- fallback_normalize_delta(device, &dispatch->wheel.hi_res, &unaccel);
- evdev_post_scroll(device,
- time,
- LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
- &unaccel);
- dispatch->wheel.hi_res.x = 0;
- dispatch->wheel.hi_res.y = 0;
-
- return;
- }
-
- if (dispatch->wheel.hi_res.y != 0) {
- int value = dispatch->wheel.hi_res.y;
-
- v120.y = -1 * value;
- wheel_degrees.y = -1 * value/120.0 * device->scroll.wheel_click_angle.y;
- evdev_notify_axis_wheel(
- device,
- time,
- bit(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL),
- &wheel_degrees,
- &v120);
- dispatch->wheel.hi_res.y = 0;
- }
-
- if (dispatch->wheel.lo_res.y != 0) {
- int value = dispatch->wheel.lo_res.y;
-
- wheel_degrees.y = -1 * value * device->scroll.wheel_click_angle.y;
- discrete.y = -1 * value;
- evdev_notify_axis_legacy_wheel(
- device,
- time,
- bit(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL),
- &wheel_degrees,
- &discrete);
- dispatch->wheel.lo_res.y = 0;
- }
-
- if (dispatch->wheel.hi_res.x != 0) {
- int value = dispatch->wheel.hi_res.x;
-
- v120.x = value;
- wheel_degrees.x = value/120.0 * device->scroll.wheel_click_angle.x;
- evdev_notify_axis_wheel(
- device,
- time,
- bit(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL),
- &wheel_degrees,
- &v120);
- dispatch->wheel.hi_res.x = 0;
- }
-
- if (dispatch->wheel.lo_res.x != 0) {
- int value = dispatch->wheel.lo_res.x;
-
- wheel_degrees.x = value * device->scroll.wheel_click_angle.x;
- discrete.x = value;
- evdev_notify_axis_legacy_wheel(
- device,
- time,
- bit(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL),
- &wheel_degrees,
- &discrete);
- dispatch->wheel.lo_res.x = 0;
- }
+ wheel_flush_scroll(dispatch, device, time);
}
void