if (t->scroll.direction != -1) {
/* Send stop scroll event */
pointer_notify_axis(device, time,
- t->scroll.direction,
+ AS_MASK(t->scroll.direction),
LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
- 0.0,
- 0);
- 0.0, 0.0);
++ 0.0, 0.0,
++ 0, 0);
t->scroll.direction = -1;
}
continue;
if (fabs(*delta) < t->scroll.threshold)
continue;
- pointer_notify_axis(device, time, axis,
+ pointer_notify_axis(device, time,
+ AS_MASK(axis),
LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
- *delta,
- 0);
- dx, dy);
++ dx, dy,
++ 0, 0);
t->scroll.direction = axis;
tp_edge_scroll_handle_event(tp, t, SCROLL_EVENT_POSTED);
tp_for_each_touch(tp, t) {
if (t->scroll.direction != -1) {
pointer_notify_axis(device, time,
- t->scroll.direction,
+ AS_MASK(t->scroll.direction),
LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
- 0.0,
- 0);
++ 0.0, 0.0,
+ 0.0, 0.0);
t->scroll.direction = -1;
}
}
static void
evdev_notify_axis(struct evdev_device *device,
uint64_t time,
- enum libinput_pointer_axis axis,
+ uint32_t axes,
enum libinput_pointer_axis_source source,
- double value,
- double discrete)
- double x, double y)
++ double x, double y,
++ double x_discrete, double y_discrete)
{
if (device->scroll.natural_scrolling_enabled) {
- value *= -1;
- discrete *= -1;
+ x *= -1;
+ y *= -1;
++ x_discrete *= -1;
++ y_discrete *= -1;
}
pointer_notify_axis(&device->base,
time,
- axis,
+ axes,
source,
- value,
- discrete);
- x, y);
++ x, y,
++ x_discrete, y_discrete);
}
static inline void
evdev_notify_axis(
device,
time,
- LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
+ AS_MASK(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL),
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL,
- 0,
- -1 * e->value * device->scroll.wheel_click_angle);
++ 0.0,
+ -1 * e->value * device->scroll.wheel_click_angle,
++ 0.0,
+ -1 * e->value);
break;
case REL_HWHEEL:
evdev_flush_pending_event(device, time);
evdev_notify_axis(
device,
time,
- LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
+ AS_MASK(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL),
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL,
e->value * device->scroll.wheel_click_angle,
- e->value);
- 0);
++ 0.0,
++ e->value,
++ 0.0);
break;
}
}
/* We use the trigger to enable, but the delta from this event for
* the actual scroll movement. Otherwise we get a jump once
* scrolling engages */
- if (dy != 0.0 &&
- evdev_is_scrolling(device,
- LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) {
- evdev_notify_axis(device,
- time,
- LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
- source,
- dy,
- 0);
- }
+ if (!evdev_is_scrolling(device,
+ LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
+ dy = 0.0;
+ if (!evdev_is_scrolling(device,
+ LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
+ dx = 0.0;
- if (dx != 0.0 &&
- evdev_is_scrolling(device,
- LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) {
+ if (dx != 0.0 || dy != 0.0)
evdev_notify_axis(device,
time,
- LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
+ device->scroll.direction,
source,
-- dx,
- 0);
- }
- dy);
++ dx, dy,
++ 0.0, 0.0);
}
void
enum libinput_pointer_axis_source source)
{
/* terminate scrolling with a zero scroll event */
- if (device->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
- pointer_notify_axis(&device->base,
- time,
- LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
- source,
- 0, 0);
- if (device->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
+ if (device->scroll.direction != 0)
pointer_notify_axis(&device->base,
time,
- LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
+ device->scroll.direction,
source,
- 0, 0);
++ 0.0, 0.0,
+ 0.0, 0.0);
device->scroll.buildup_horizontal = 0;
device->scroll.buildup_vertical = 0;
void
pointer_notify_axis(struct libinput_device *device,
uint64_t time,
- enum libinput_pointer_axis axis,
+ uint32_t axes,
enum libinput_pointer_axis_source source,
- double value,
- double discrete);
- double x, double y);
++ double x,
++ double y,
++ double x_discrete,
++ double y_discrete);
void
touch_notify_touch_down(struct libinput_device *device,
uint32_t time;
double x;
double y;
++ double x_discrete;
++ double y_discrete;
double dx_unaccel;
double dy_unaccel;
uint32_t button;
}
LIBINPUT_EXPORT double
- libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event)
+ libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event,
+ enum libinput_pointer_axis axis)
{
- return event->value;
+ struct libinput *libinput = event->base.device->seat->libinput;
+ double value = 0;
+
+ if (!libinput_event_pointer_has_axis(event, axis)) {
+ log_bug_client(libinput, "value requested for unset axis\n");
+ } else {
+ switch (axis) {
+ case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
+ value = event->x;
+ break;
+ case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
+ value = event->y;
+ break;
+ }
+ }
+
+ return value;
}
- libinput_event_pointer_get_axis_value_discrete(struct libinput_event_pointer *event)
+LIBINPUT_EXPORT double
- return event->discrete;
++libinput_event_pointer_get_axis_value_discrete(struct libinput_event_pointer *event,
++ enum libinput_pointer_axis axis)
+{
++ struct libinput *libinput = event->base.device->seat->libinput;
++ double value = 0;
++
++ if (!libinput_event_pointer_has_axis(event, axis)) {
++ log_bug_client(libinput, "value requested for unset axis\n");
++ } else {
++ switch (axis) {
++ case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
++ value = event->x_discrete;
++ break;
++ case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
++ value = event->y_discrete;
++ break;
++ }
++ }
++ return value;
+}
+
LIBINPUT_EXPORT enum libinput_pointer_axis_source
libinput_event_pointer_get_axis_source(struct libinput_event_pointer *event)
{
void
pointer_notify_axis(struct libinput_device *device,
uint64_t time,
- enum libinput_pointer_axis axis,
+ uint32_t axes,
enum libinput_pointer_axis_source source,
- double value,
- double discrete)
- double x, double y)
++ double x, double y,
++ double x_discrete, double y_discrete)
{
struct libinput_event_pointer *axis_event;
*axis_event = (struct libinput_event_pointer) {
.time = time,
- .axis = axis,
- .value = value,
+ .x = x,
+ .y = y,
.source = source,
- .discrete = discrete,
+ .axes = axes,
++ .x_discrete = x_discrete,
++ .y_discrete = y_discrete,
};
post_device_event(device, time,
* @ref LIBINPUT_EVENT_POINTER_AXIS.
*
* @return the axis value of this event
+ *
+ * @see libinput_event_pointer_get_axis_value_discrete
*/
double
- libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event);
+ libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event,
+ enum libinput_pointer_axis axis);
/**
* @ingroup event_pointer
enum libinput_pointer_axis_source
libinput_event_pointer_get_axis_source(struct libinput_event_pointer *event);
- libinput_event_pointer_get_axis_value_discrete(struct libinput_event_pointer *event);
+/**
+ * @ingroup pointer
+ *
+ * Return the axis value in discrete steps for a given axis event. How a
+ * value translates into a discrete step depends on the source.
+ *
+ * If the source is @ref LIBINPUT_POINTER_AXIS_SOURCE_WHEEL, the discrete
+ * value correspond to the number of physical mouse clicks.
+ *
+ * If the source is @ref LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS or @ref
+ * LIBINPUT_POINTER_AXIS_SOURCE_FINGER, the discrete value is always 0.
+ *
+ * @return The discrete value for the given event.
+ *
+ * @see libinput_event_pointer_get_axis_value
+ */
+double
++libinput_event_pointer_get_axis_value_discrete(struct libinput_event_pointer *event,
++ enum libinput_pointer_axis axis);
+
/**
* @ingroup event_pointer
*
ptrev = libinput_event_get_pointer_event(event);
ck_assert(ptrev != NULL);
- ck_assert_int_eq(libinput_event_pointer_get_axis(ptrev),
- which == REL_WHEEL ?
+
+ axis = (which == REL_WHEEL) ?
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL :
- LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
- ck_assert_int_eq(libinput_event_pointer_get_axis_value(ptrev), expected);
+ LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
+
+ ck_assert_int_eq(libinput_event_pointer_get_axis_value(ptrev, axis),
+ expected);
ck_assert_int_eq(libinput_event_pointer_get_axis_source(ptrev),
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL);
- ck_assert_int_eq(libinput_event_pointer_get_axis_value_discrete(ptrev),
++ ck_assert_int_eq(libinput_event_pointer_get_axis_value_discrete(ptrev, axis),
+ discrete);
libinput_event_destroy(event);
}