mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-04-17 10:20:44 +02:00
Add another data type for discrete coordinates
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
1b70842f9e
commit
1df0208f4f
4 changed files with 32 additions and 23 deletions
|
|
@ -315,6 +315,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
|
|||
double initial_dx, initial_dy, *initial_delta;
|
||||
struct normalized_coords normalized;
|
||||
const struct normalized_coords zero = { 0.0, 0.0 };
|
||||
const struct discrete_coords zero_discrete = { 0.0, 0.0 };
|
||||
|
||||
if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_EDGE)
|
||||
return 0;
|
||||
|
|
@ -331,7 +332,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
|
|||
AS_MASK(t->scroll.direction),
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
|
||||
&zero,
|
||||
0, 0);
|
||||
&zero_discrete);
|
||||
t->scroll.direction = -1;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -383,7 +384,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
|
|||
AS_MASK(axis),
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
|
||||
&normalized,
|
||||
0, 0);
|
||||
&zero_discrete);
|
||||
t->scroll.direction = axis;
|
||||
|
||||
tp_edge_scroll_handle_event(tp, t, SCROLL_EVENT_POSTED);
|
||||
|
|
@ -398,6 +399,7 @@ tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time)
|
|||
struct libinput_device *device = &tp->device->base;
|
||||
struct tp_touch *t;
|
||||
const struct normalized_coords zero = { 0.0, 0.0 };
|
||||
const struct discrete_coords zero_discrete = { 0.0, 0.0 };
|
||||
|
||||
tp_for_each_touch(tp, t) {
|
||||
if (t->scroll.direction != -1) {
|
||||
|
|
@ -405,7 +407,7 @@ tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time)
|
|||
AS_MASK(t->scroll.direction),
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
|
||||
&zero,
|
||||
0.0, 0.0);
|
||||
&zero_discrete);
|
||||
t->scroll.direction = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
src/evdev.c
27
src/evdev.c
|
|
@ -586,15 +586,16 @@ evdev_notify_axis(struct evdev_device *device,
|
|||
uint32_t axes,
|
||||
enum libinput_pointer_axis_source source,
|
||||
const struct normalized_coords *delta_in,
|
||||
double x_discrete, double y_discrete)
|
||||
const struct discrete_coords *discrete_in)
|
||||
{
|
||||
struct normalized_coords delta = *delta_in;
|
||||
struct discrete_coords discrete = *discrete_in;
|
||||
|
||||
if (device->scroll.natural_scrolling_enabled) {
|
||||
delta.x *= -1;
|
||||
delta.y *= -1;
|
||||
x_discrete *= -1;
|
||||
y_discrete *= -1;
|
||||
discrete.x *= -1;
|
||||
discrete.y *= -1;
|
||||
}
|
||||
|
||||
pointer_notify_axis(&device->base,
|
||||
|
|
@ -602,7 +603,7 @@ evdev_notify_axis(struct evdev_device *device,
|
|||
axes,
|
||||
source,
|
||||
&delta,
|
||||
x_discrete, y_discrete);
|
||||
&discrete);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
@ -610,6 +611,7 @@ evdev_process_relative(struct evdev_device *device,
|
|||
struct input_event *e, uint64_t time)
|
||||
{
|
||||
struct normalized_coords wheel_degrees = { 0.0, 0.0 };
|
||||
struct discrete_coords discrete = { 0.0, 0.0 };
|
||||
|
||||
switch (e->code) {
|
||||
case REL_X:
|
||||
|
|
@ -628,26 +630,26 @@ evdev_process_relative(struct evdev_device *device,
|
|||
evdev_flush_pending_event(device, time);
|
||||
wheel_degrees.y = -1 * e->value *
|
||||
device->scroll.wheel_click_angle;
|
||||
discrete.y = -1 * e->value;
|
||||
evdev_notify_axis(
|
||||
device,
|
||||
time,
|
||||
AS_MASK(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL),
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL,
|
||||
&wheel_degrees,
|
||||
0.0,
|
||||
-1 * e->value);
|
||||
&discrete);
|
||||
break;
|
||||
case REL_HWHEEL:
|
||||
evdev_flush_pending_event(device, time);
|
||||
wheel_degrees.x = e->value * device->scroll.wheel_click_angle;
|
||||
discrete.x = e->value;
|
||||
evdev_notify_axis(
|
||||
device,
|
||||
time,
|
||||
AS_MASK(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL),
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL,
|
||||
&wheel_degrees,
|
||||
e->value,
|
||||
0.0);
|
||||
&discrete);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1977,13 +1979,15 @@ evdev_post_scroll(struct evdev_device *device,
|
|||
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
|
||||
event.x = 0.0;
|
||||
|
||||
if (event.x != 0.0 || event.y != 0.0)
|
||||
if (event.x != 0.0 || event.y != 0.0) {
|
||||
const struct discrete_coords zero_discrete = { 0.0, 0.0 };
|
||||
evdev_notify_axis(device,
|
||||
time,
|
||||
device->scroll.direction,
|
||||
source,
|
||||
&event,
|
||||
0.0, 0.0);
|
||||
&zero_discrete);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1992,6 +1996,7 @@ evdev_stop_scroll(struct evdev_device *device,
|
|||
enum libinput_pointer_axis_source source)
|
||||
{
|
||||
const struct normalized_coords zero = { 0.0, 0.0 };
|
||||
const struct discrete_coords zero_discrete = { 0.0, 0.0 };
|
||||
|
||||
/* terminate scrolling with a zero scroll event */
|
||||
if (device->scroll.direction != 0)
|
||||
|
|
@ -2000,7 +2005,7 @@ evdev_stop_scroll(struct evdev_device *device,
|
|||
device->scroll.direction,
|
||||
source,
|
||||
&zero,
|
||||
0.0, 0.0);
|
||||
&zero_discrete);
|
||||
|
||||
device->scroll.buildup.x = 0;
|
||||
device->scroll.buildup.y = 0;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ struct normalized_coords {
|
|||
double x, y;
|
||||
};
|
||||
|
||||
/* A discrete step pair (mouse wheels) */
|
||||
struct discrete_coords {
|
||||
int x, y;
|
||||
};
|
||||
|
||||
struct libinput_interface_backend {
|
||||
int (*resume)(struct libinput *libinput);
|
||||
void (*suspend)(struct libinput *libinput);
|
||||
|
|
@ -310,8 +315,7 @@ pointer_notify_axis(struct libinput_device *device,
|
|||
uint32_t axes,
|
||||
enum libinput_pointer_axis_source source,
|
||||
const struct normalized_coords *delta,
|
||||
double x_discrete,
|
||||
double y_discrete);
|
||||
const struct discrete_coords *discrete);
|
||||
|
||||
void
|
||||
touch_notify_touch_down(struct libinput_device *device,
|
||||
|
|
|
|||
|
|
@ -95,8 +95,7 @@ struct libinput_event_pointer {
|
|||
uint32_t time;
|
||||
struct normalized_coords delta;
|
||||
struct device_coords absolute;
|
||||
double x_discrete;
|
||||
double y_discrete;
|
||||
struct discrete_coords discrete;
|
||||
double dx_unaccel;
|
||||
double dy_unaccel;
|
||||
uint32_t button;
|
||||
|
|
@ -511,10 +510,10 @@ libinput_event_pointer_get_axis_value_discrete(struct libinput_event_pointer *ev
|
|||
} else {
|
||||
switch (axis) {
|
||||
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
|
||||
value = event->x_discrete;
|
||||
value = event->discrete.x;
|
||||
break;
|
||||
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
||||
value = event->y_discrete;
|
||||
value = event->discrete.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1174,7 +1173,7 @@ pointer_notify_axis(struct libinput_device *device,
|
|||
uint32_t axes,
|
||||
enum libinput_pointer_axis_source source,
|
||||
const struct normalized_coords *delta,
|
||||
double x_discrete, double y_discrete)
|
||||
const struct discrete_coords *discrete)
|
||||
{
|
||||
struct libinput_event_pointer *axis_event;
|
||||
|
||||
|
|
@ -1187,8 +1186,7 @@ pointer_notify_axis(struct libinput_device *device,
|
|||
.delta = *delta,
|
||||
.source = source,
|
||||
.axes = axes,
|
||||
.x_discrete = x_discrete,
|
||||
.y_discrete = y_discrete,
|
||||
.discrete = *discrete,
|
||||
};
|
||||
|
||||
post_device_event(device, time,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue