mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 11:55:59 +01:00
backend/libinput: handle high-res scroll events
On newer versions of libinput, the event LIBINPUT_EVENT_POINTER_AXIS has been deprecated in favour of LIBINPUT_EVENT_POINTER_SCROLL_WHEEL, LIBINPUT_EVENT_POINTER_SCROLL_FINGER and LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS. Where new events are provided by the backend, ignore LIBINPUT_EVENT_POINTER_AXIS, receive high-resolution scroll events from libinput and emit the appropiate wlr_pointer signal.
This commit is contained in:
parent
65c436407f
commit
c6032d6b1c
3 changed files with 60 additions and 0 deletions
|
@ -176,8 +176,25 @@ void handle_libinput_event(struct wlr_libinput_backend *backend,
|
||||||
handle_pointer_button(event, &dev->pointer);
|
handle_pointer_button(event, &dev->pointer);
|
||||||
break;
|
break;
|
||||||
case LIBINPUT_EVENT_POINTER_AXIS:
|
case LIBINPUT_EVENT_POINTER_AXIS:
|
||||||
|
#if !LIBINPUT_HAS_SCROLL_VALUE120
|
||||||
|
/* This event must be ignored in favour of the SCROLL_* events */
|
||||||
handle_pointer_axis(event, &dev->pointer);
|
handle_pointer_axis(event, &dev->pointer);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
#if LIBINPUT_HAS_SCROLL_VALUE120
|
||||||
|
case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL:
|
||||||
|
handle_pointer_axis_value120(event, &dev->pointer,
|
||||||
|
WLR_AXIS_SOURCE_WHEEL);
|
||||||
|
break;
|
||||||
|
case LIBINPUT_EVENT_POINTER_SCROLL_FINGER:
|
||||||
|
handle_pointer_axis_value120(event, &dev->pointer,
|
||||||
|
WLR_AXIS_SOURCE_FINGER);
|
||||||
|
break;
|
||||||
|
case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS:
|
||||||
|
handle_pointer_axis_value120(event, &dev->pointer,
|
||||||
|
WLR_AXIS_SOURCE_CONTINUOUS);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
case LIBINPUT_EVENT_TOUCH_DOWN:
|
case LIBINPUT_EVENT_TOUCH_DOWN:
|
||||||
handle_touch_down(event, &dev->touch);
|
handle_touch_down(event, &dev->touch);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -123,6 +123,45 @@ void handle_pointer_axis(struct libinput_event *event,
|
||||||
wlr_signal_emit_safe(&pointer->events.frame, pointer);
|
wlr_signal_emit_safe(&pointer->events.frame, pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LIBINPUT_HAS_SCROLL_VALUE120
|
||||||
|
void handle_pointer_axis_value120(struct libinput_event *event,
|
||||||
|
struct wlr_pointer *pointer, enum wlr_axis_source source) {
|
||||||
|
struct libinput_event_pointer *pevent =
|
||||||
|
libinput_event_get_pointer_event(event);
|
||||||
|
struct wlr_pointer_axis_event wlr_event = { 0 };
|
||||||
|
wlr_event.pointer = pointer;
|
||||||
|
wlr_event.time_msec =
|
||||||
|
usec_to_msec(libinput_event_pointer_get_time_usec(pevent));
|
||||||
|
wlr_event.source = source;
|
||||||
|
|
||||||
|
const enum libinput_pointer_axis axes[] = {
|
||||||
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
||||||
|
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
|
||||||
|
};
|
||||||
|
for (size_t i = 0; i < sizeof(axes) / sizeof(axes[0]); ++i) {
|
||||||
|
if (!libinput_event_pointer_has_axis(pevent, axes[i])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch (axes[i]) {
|
||||||
|
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
||||||
|
wlr_event.orientation = WLR_AXIS_ORIENTATION_VERTICAL;
|
||||||
|
break;
|
||||||
|
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
|
||||||
|
wlr_event.orientation = WLR_AXIS_ORIENTATION_HORIZONTAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
wlr_event.delta =
|
||||||
|
libinput_event_pointer_get_scroll_value(pevent, axes[i]);
|
||||||
|
if (source == WLR_AXIS_SOURCE_WHEEL) {
|
||||||
|
wlr_event.delta_discrete =
|
||||||
|
libinput_event_pointer_get_scroll_value_v120(pevent, axes[i]);
|
||||||
|
}
|
||||||
|
wlr_signal_emit_safe(&pointer->events.axis, &wlr_event);
|
||||||
|
}
|
||||||
|
wlr_signal_emit_safe(&pointer->events.frame, pointer);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void handle_pointer_swipe_begin(struct libinput_event *event,
|
void handle_pointer_swipe_begin(struct libinput_event *event,
|
||||||
struct wlr_pointer *pointer) {
|
struct wlr_pointer *pointer) {
|
||||||
struct libinput_event_gesture *gevent =
|
struct libinput_event_gesture *gevent =
|
||||||
|
|
|
@ -70,6 +70,10 @@ void handle_pointer_button(struct libinput_event *event,
|
||||||
struct wlr_pointer *pointer);
|
struct wlr_pointer *pointer);
|
||||||
void handle_pointer_axis(struct libinput_event *event,
|
void handle_pointer_axis(struct libinput_event *event,
|
||||||
struct wlr_pointer *pointer);
|
struct wlr_pointer *pointer);
|
||||||
|
#if LIBINPUT_HAS_SCROLL_VALUE120
|
||||||
|
void handle_pointer_axis_value120(struct libinput_event *event,
|
||||||
|
struct wlr_pointer *pointer, enum wlr_axis_source source);
|
||||||
|
#endif
|
||||||
void handle_pointer_swipe_begin(struct libinput_event *event,
|
void handle_pointer_swipe_begin(struct libinput_event *event,
|
||||||
struct wlr_pointer *pointer);
|
struct wlr_pointer *pointer);
|
||||||
void handle_pointer_swipe_update(struct libinput_event *event,
|
void handle_pointer_swipe_update(struct libinput_event *event,
|
||||||
|
|
Loading…
Reference in a new issue