mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-02-05 04:06:11 -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
|
|
@ -262,6 +262,20 @@ void handle_libinput_event(struct wlr_libinput_backend *backend,
|
|||
handle_pointer_axis(event, libinput_dev);
|
||||
#endif
|
||||
break;
|
||||
#if LIBINPUT_HAS_SCROLL_VALUE120
|
||||
case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL:
|
||||
handle_pointer_axis_value120(event, libinput_dev,
|
||||
WLR_AXIS_SOURCE_WHEEL);
|
||||
break;
|
||||
case LIBINPUT_EVENT_POINTER_SCROLL_FINGER:
|
||||
handle_pointer_axis_value120(event, libinput_dev,
|
||||
WLR_AXIS_SOURCE_FINGER);
|
||||
break;
|
||||
case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS:
|
||||
handle_pointer_axis_value120(event, libinput_dev,
|
||||
WLR_AXIS_SOURCE_CONTINUOUS);
|
||||
break;
|
||||
#endif
|
||||
case LIBINPUT_EVENT_TOUCH_DOWN:
|
||||
handle_touch_down(event, libinput_dev);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <wlr/backend/libinput.h>
|
||||
#include <wlr/interfaces/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_pointer.h>
|
||||
|
||||
struct wlr_libinput_backend {
|
||||
struct wlr_backend backend;
|
||||
|
|
@ -54,6 +55,11 @@ void handle_pointer_button(struct libinput_event *event,
|
|||
struct libinput_device *device);
|
||||
void handle_pointer_axis(struct libinput_event *event,
|
||||
struct libinput_device *device);
|
||||
#if LIBINPUT_HAS_SCROLL_VALUE120
|
||||
void handle_pointer_axis_value120(struct libinput_event *event,
|
||||
struct libinput_device *device,
|
||||
enum wlr_axis_source source);
|
||||
#endif
|
||||
void handle_pointer_swipe_begin(struct libinput_event *event,
|
||||
struct libinput_device *device);
|
||||
void handle_pointer_swipe_update(struct libinput_event *event,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue