fallback: replace fallback_dispatch->wheel with an anonymous struct

The current fallback_dispatch wheel struct, a device_coords, doesn't allow to
save extra information.
The new anonymous struct will allow to add a is_inhibited field to disable mouse
scroll while the middle button is pressed and, potentially, any required extra
state in the future.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
This commit is contained in:
JoseExposito 2021-03-11 08:30:45 +01:00 committed by Peter Hutterer
parent 06697b5e85
commit 0f79fe6677
2 changed files with 18 additions and 15 deletions

View file

@ -215,22 +215,22 @@ fallback_flush_wheels(struct fallback_dispatch *dispatch,
if (device->model_flags & EVDEV_MODEL_LENOVO_SCROLLPOINT) {
struct normalized_coords unaccel = { 0.0, 0.0 };
dispatch->wheel.y *= -1;
normalize_delta(device, &dispatch->wheel, &unaccel);
dispatch->wheel.delta.y *= -1;
normalize_delta(device, &dispatch->wheel.delta, &unaccel);
evdev_post_scroll(device,
time,
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
&unaccel);
dispatch->wheel.x = 0;
dispatch->wheel.y = 0;
dispatch->wheel.delta.x = 0;
dispatch->wheel.delta.y = 0;
return;
}
if (dispatch->wheel.y != 0) {
wheel_degrees.y = -1 * dispatch->wheel.y *
if (dispatch->wheel.delta.y != 0) {
wheel_degrees.y = -1 * dispatch->wheel.delta.y *
device->scroll.wheel_click_angle.y;
discrete.y = -1 * dispatch->wheel.y;
discrete.y = -1 * dispatch->wheel.delta.y;
evdev_notify_axis(
device,
@ -239,13 +239,13 @@ fallback_flush_wheels(struct fallback_dispatch *dispatch,
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL,
&wheel_degrees,
&discrete);
dispatch->wheel.y = 0;
dispatch->wheel.delta.y = 0;
}
if (dispatch->wheel.x != 0) {
wheel_degrees.x = dispatch->wheel.x *
if (dispatch->wheel.delta.x != 0) {
wheel_degrees.x = dispatch->wheel.delta.x *
device->scroll.wheel_click_angle.x;
discrete.x = dispatch->wheel.x;
discrete.x = dispatch->wheel.delta.x;
evdev_notify_axis(
device,
@ -254,7 +254,7 @@ fallback_flush_wheels(struct fallback_dispatch *dispatch,
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL,
&wheel_degrees,
&discrete);
dispatch->wheel.x = 0;
dispatch->wheel.delta.x = 0;
}
}
@ -827,11 +827,11 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
dispatch->pending_event |= EVDEV_RELATIVE_MOTION;
break;
case REL_WHEEL:
dispatch->wheel.y += e->value;
dispatch->wheel.delta.y += e->value;
dispatch->pending_event |= EVDEV_WHEEL;
break;
case REL_HWHEEL:
dispatch->wheel.x += e->value;
dispatch->wheel.delta.x += e->value;
dispatch->pending_event |= EVDEV_WHEEL;
break;
}

View file

@ -96,7 +96,10 @@ struct fallback_dispatch {
} mt;
struct device_coords rel;
struct device_coords wheel;
struct {
struct device_coords delta;
} wheel;
struct {
/* The struct for the tablet mode switch device itself */