mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-02-07 04:06:14 -05:00
backend/libinput: handle high-res scroll events
Receive high-resolution scroll events from libinput and emit the appropiate wlr_pointer signal.
This commit is contained in:
parent
763cf1915b
commit
d18b85c88a
3 changed files with 65 additions and 0 deletions
|
|
@ -141,6 +141,51 @@ void handle_pointer_axis(struct libinput_event *event,
|
|||
wlr_signal_emit_safe(&wlr_dev->pointer->events.frame, wlr_dev->pointer);
|
||||
}
|
||||
|
||||
#if LIBINPUT_HAS_SCROLL_VALUE120
|
||||
void handle_pointer_axis_value120(struct libinput_event *event,
|
||||
struct libinput_device *device,
|
||||
enum wlr_axis_source source) {
|
||||
struct wlr_input_device *wlr_dev =
|
||||
get_appropriate_device(WLR_INPUT_DEVICE_POINTER, device);
|
||||
if (!wlr_dev) {
|
||||
wlr_log(WLR_DEBUG, "Got a pointer event for a device with no pointers?");
|
||||
return;
|
||||
}
|
||||
struct libinput_event_pointer *pevent =
|
||||
libinput_event_get_pointer_event(event);
|
||||
struct wlr_event_pointer_axis_value120 wlr_event = { 0 };
|
||||
wlr_event.device = wlr_dev;
|
||||
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])) {
|
||||
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_value120 =
|
||||
libinput_event_pointer_get_scroll_value_v120(pevent, axes[i]);
|
||||
}
|
||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.axis_value120, &wlr_event);
|
||||
}
|
||||
}
|
||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.frame, wlr_dev->pointer);
|
||||
}
|
||||
#endif
|
||||
|
||||
void handle_pointer_swipe_begin(struct libinput_event *event,
|
||||
struct libinput_device *libinput_dev) {
|
||||
struct wlr_input_device *wlr_dev =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue