mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 03:20:05 +01:00
plugin: only register the wheel plugin on devices that have a wheel
Touchpad devices are pointers too in libinput but they don't usually
have wheels. Let's check for REL_WHEEL in device_new *and* then again
for the actual pointer capability in device_added.
Fixes: d1800a76fe ("evdev: Handle scroll wheel with a plugin")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1251>
This commit is contained in:
parent
d458b86240
commit
31854a829a
1 changed files with 29 additions and 5 deletions
|
|
@ -463,10 +463,13 @@ wheel_plugin_destroy(struct libinput_plugin *libinput_plugin)
|
|||
}
|
||||
|
||||
static void
|
||||
wheel_plugin_device_added(struct libinput_plugin *libinput_plugin,
|
||||
struct libinput_device *device)
|
||||
wheel_plugin_device_new(struct libinput_plugin *libinput_plugin,
|
||||
struct libinput_device *device,
|
||||
struct libevdev *libevdev,
|
||||
struct udev_device *udev_device)
|
||||
{
|
||||
if (!libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
|
||||
if (!libevdev_has_event_code(libevdev, EV_REL, REL_WHEEL_HI_RES) &&
|
||||
!libevdev_has_event_code(libevdev, EV_REL, REL_HWHEEL_HI_RES))
|
||||
return;
|
||||
|
||||
libinput_plugin_enable_device_event_frame(libinput_plugin, device, true);
|
||||
|
|
@ -477,6 +480,27 @@ wheel_plugin_device_added(struct libinput_plugin *libinput_plugin,
|
|||
list_take_append(&plugin->devices, pd, link);
|
||||
}
|
||||
|
||||
static void
|
||||
wheel_plugin_device_added(struct libinput_plugin *libinput_plugin,
|
||||
struct libinput_device *device)
|
||||
{
|
||||
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
|
||||
return;
|
||||
|
||||
/* For any non-pointer device: check if we happened to have added
|
||||
* it during device_new and if so, remove it. We only want to enable
|
||||
* this on devices that have a wheel *and* are a pointer device */
|
||||
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
|
||||
struct plugin_device *pd;
|
||||
|
||||
list_for_each_safe(pd, &plugin->devices, link) {
|
||||
if (pd->device == device) {
|
||||
wheel_plugin_device_destroy(pd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
wheel_plugin_device_removed(struct libinput_plugin *libinput_plugin,
|
||||
struct libinput_device *device)
|
||||
|
|
@ -533,8 +557,8 @@ wheel_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
|
|||
static const struct libinput_plugin_interface interface = {
|
||||
.run = NULL,
|
||||
.destroy = wheel_plugin_destroy,
|
||||
.device_new = NULL,
|
||||
.device_ignored = NULL,
|
||||
.device_new = wheel_plugin_device_new,
|
||||
.device_ignored = wheel_plugin_device_removed,
|
||||
.device_added = wheel_plugin_device_added,
|
||||
.device_removed = wheel_plugin_device_removed,
|
||||
.evdev_frame = wheel_plugin_evdev_frame,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue