libinput 1.28.902

This commit is contained in:
Peter Hutterer 2025-07-17 13:09:24 +10:00
commit 86954d38cd
4 changed files with 6 additions and 366 deletions

View file

@ -1,208 +0,0 @@
From 5f44eebff87b13977f0eeca5356cf00228f285b6 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon, 14 Jul 2025 10:05:22 +1000
Subject: [PATCH] plugins: add a plugin to emulate high-resolution wheel events
Fixes a regression causing missing scroll events on devices where the
kernel only sets REL_WHEEL/REL_HWHEEL but not the corresponding
hires events. On those devices we would get the legacy axis events but
no longer the new ones.
The mouse wheel plugin will correctly emulate missing hires events
but it doesn't attach to devices where the hires bit is never set.
This plugin can be very simple - since we know we enabled the code on
this device we don't need to keep any extra state around. If our frame
handler is called for this device we want to add the hi-res events.
Theoretically this breaks if the device has only one hi-res axis enabled
but not the other one (i.e. REL_WHEEL_HI_RES but only REL_HWHEEL) but
that's too theoretical to worry about.
Closes #1156
Fixes: 31854a829a21 ("plugin: only register the wheel plugin on devices that have a wheel")
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
meson.build | 1 +
src/libinput-plugin-mouse-wheel-lowres.c | 97 ++++++++++++++++++++++++
src/libinput-plugin-mouse-wheel-lowres.h | 30 ++++++++
src/libinput-plugin.c | 2 +
4 files changed, 130 insertions(+)
create mode 100644 src/libinput-plugin-mouse-wheel-lowres.c
create mode 100644 src/libinput-plugin-mouse-wheel-lowres.h
diff --git a/meson.build b/meson.build
index e5932754bc9f..e51357885ae9 100644
--- a/meson.build
+++ b/meson.build
@@ -384,6 +384,7 @@ src_libinput = src_libfilter + [
'src/libinput-plugin.c',
'src/libinput-plugin-button-debounce.c',
'src/libinput-plugin-mouse-wheel.c',
+ 'src/libinput-plugin-mouse-wheel-lowres.c',
'src/libinput-plugin-tablet-double-tool.c',
'src/libinput-plugin-tablet-eraser-button.c',
'src/libinput-plugin-tablet-forced-tool.c',
diff --git a/src/libinput-plugin-mouse-wheel-lowres.c b/src/libinput-plugin-mouse-wheel-lowres.c
new file mode 100644
index 000000000000..ce3847e2e002
--- /dev/null
+++ b/src/libinput-plugin-mouse-wheel-lowres.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2025 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "config.h"
+
+#include <libevdev/libevdev.h>
+
+#include "evdev.h"
+#include "libinput-plugin-mouse-wheel-lowres.h"
+#include "libinput-plugin.h"
+#include "src/evdev-frame.h"
+
+static void
+wheel_plugin_device_new(struct libinput_plugin *libinput_plugin,
+ struct libinput_device *device,
+ struct libevdev *libevdev,
+ struct udev_device *udev_device)
+{
+ struct evdev_device *evdev = evdev_device(device);
+
+ if (libevdev_has_event_code(libevdev, EV_REL, REL_WHEEL_HI_RES) ||
+ libevdev_has_event_code(libevdev, EV_REL, REL_HWHEEL_HI_RES))
+ return;
+
+ if (libevdev_has_event_code(libevdev, EV_REL, REL_WHEEL) ||
+ libevdev_has_event_code(libevdev, EV_REL, REL_HWHEEL))
+ evdev_log_info(evdev,
+ "emulating high-resolution scroll wheel events.\n");
+
+ if (libevdev_has_event_code(libevdev, EV_REL, REL_WHEEL))
+ libevdev_enable_event_code(libevdev, EV_REL, REL_WHEEL_HI_RES, NULL);
+
+ if (libevdev_has_event_code(libevdev, EV_REL, REL_HWHEEL))
+ libevdev_enable_event_code(libevdev, EV_REL, REL_HWHEEL_HI_RES, NULL);
+
+ libinput_plugin_enable_device_event_frame(libinput_plugin, device, true);
+}
+
+static void
+wheel_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
+ struct libinput_device *device,
+ struct evdev_frame *frame)
+{
+ size_t nevents;
+ struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
+
+ for (size_t i = 0; i < nevents; i++) {
+ struct evdev_event *e = &events[i];
+ switch (evdev_usage_enum(e->usage)) {
+ case EVDEV_REL_WHEEL:
+ evdev_frame_append_one(frame,
+ evdev_usage_from(EVDEV_REL_WHEEL_HI_RES),
+ e->value * 120);
+ break;
+ case EVDEV_REL_HWHEEL:
+ evdev_frame_append_one(
+ frame,
+ evdev_usage_from(EVDEV_REL_HWHEEL_HI_RES),
+ e->value * 120);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+static const struct libinput_plugin_interface interface = {
+ .device_new = wheel_plugin_device_new,
+ .evdev_frame = wheel_plugin_evdev_frame,
+};
+
+void
+libinput_mouse_plugin_wheel_lowres(struct libinput *libinput)
+{
+ _unref_(libinput_plugin) *p =
+ libinput_plugin_new(libinput, "mouse-wheel-lowres", &interface, NULL);
+}
diff --git a/src/libinput-plugin-mouse-wheel-lowres.h b/src/libinput-plugin-mouse-wheel-lowres.h
new file mode 100644
index 000000000000..9fee3ec3cb1c
--- /dev/null
+++ b/src/libinput-plugin-mouse-wheel-lowres.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright © 2025 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "config.h"
+
+#include "libinput-plugin.h"
+#include "libinput.h"
+
+void
+libinput_mouse_plugin_wheel_lowres(struct libinput *libinput);
diff --git a/src/libinput-plugin.c b/src/libinput-plugin.c
index c14ae33751d4..6e0f068cd45c 100644
--- a/src/libinput-plugin.c
+++ b/src/libinput-plugin.c
@@ -30,6 +30,7 @@
#include "evdev-plugin.h"
#include "libinput-plugin-button-debounce.h"
+#include "libinput-plugin-mouse-wheel-lowres.h"
#include "libinput-plugin-mouse-wheel.h"
#include "libinput-plugin-mtdev.h"
#include "libinput-plugin-private.h"
@@ -390,6 +391,7 @@ libinput_plugin_system_load_internal_plugins(struct libinput *libinput,
libinput_tablet_plugin_proximity_timer(libinput);
libinput_tablet_plugin_eraser_button(libinput);
libinput_debounce_plugin(libinput);
+ libinput_mouse_plugin_wheel_lowres(libinput);
libinput_mouse_plugin_wheel(libinput);
/* Our own event dispatch is implemented as mini-plugin,
--
2.50.0

View file

@ -1,152 +0,0 @@
From 25f40a788d6c2fdefb373761e318abb29c5c6f60 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue, 15 Jul 2025 21:29:43 +1000
Subject: [PATCH] evdev: track KEY_SYSRQ frames and pass them even as repeat
frames
Alt+Printscreen aka KEY_LEFTALT + KEY_SYSRQ is emulated by the kernel
and always posted with SYN_REPORT 1, see
drivers/tty/sysrq.c:sysrq_reinject_alt_sysrq()
The actual sequence when pressing Alt + Printscreen is to release Alt
first, then press it again:
- evdev:
- [ 10, 674010, 1, 56, 0] # EV_KEY / KEY_LEFTALT 0
- [ 10, 674010, 0, 0, 0] # ------------ SYN_REPORT (0) ---------- +2861ms
- evdev:
- [ 10, 674030, 1, 56, 1] # EV_KEY / KEY_LEFTALT 1
- [ 10, 674030, 1, 99, 1] # EV_KEY / KEY_SYSRQ 1
- [ 10, 674030, 0, 0, 1] # ------------ SYN_REPORT (1) ---------- +0ms
- evdev:
- [ 10, 674031, 1, 99, 0] # EV_KEY / KEY_SYSRQ 0
- [ 10, 674031, 1, 56, 0] # EV_KEY / KEY_LEFTALT 0
- [ 10, 674031, 0, 0, 1] # ------------ SYN_REPORT (1) ---------- +0ms
Handle that special case so we get our printscreen key to work as
expected anymore.
Fixes: 9a9466b6a92c ("evdev: discard any frame with EV_SYN SYN_REPORT 1")
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
src/evdev.c | 13 +++++++++-
test/test-keyboard.c | 57 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/src/evdev.c b/src/evdev.c
index 5e52f4fc69e2..d0ef1c252fb3 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1043,6 +1043,7 @@ evdev_device_dispatch(void *data)
struct input_event ev;
int rc;
bool once = false;
+ bool had_sysrq = false;
_unref_(evdev_frame) *frame = evdev_frame_new(64);
/* If the compositor is repainting, this function is called only once
@@ -1083,17 +1084,27 @@ evdev_device_dispatch(void *data)
device,
"event frame overflow, discarding events.\n");
}
+ /* Alt+Printscreen is always a repeat frame, see
+ * drivers/tty/sysrq.c:sysrq_reinject_alt_sysrq() in the
+ * kernel
+ */
+ if (ev.type == EV_KEY && ev.code == KEY_SYSRQ)
+ had_sysrq = true;
+
if (ev.type == EV_SYN && ev.code == SYN_REPORT) {
/* A SYN_REPORT 1 event is a kernel-inserted
* auto-repeat. Nothing in libinput cares about kernel
* repeats and the inserted frame causes issues with
* timestamp deltas (see e.g. #1145)
+ *
+ * (well, except Alt+Printscreen (KEY_SYSRQ))
*/
- if (ev.value != 1)
+ if (ev.value != 1 || had_sysrq)
evdev_device_dispatch_frame(libinput,
device,
frame);
evdev_frame_reset(frame);
+ had_sysrq = false;
}
} else if (rc == -ENODEV) {
evdev_device_remove(device);
diff --git a/test/test-keyboard.c b/test/test-keyboard.c
index 4e1baf7f0d41..380727b25f40 100644
--- a/test/test-keyboard.c
+++ b/test/test-keyboard.c
@@ -468,6 +468,61 @@ START_TEST(keyboard_no_scroll)
}
END_TEST
+START_TEST(keyboard_alt_printscreen)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+
+ litest_drain_events(li);
+
+ /* repeat frame, ignored */
+ litest_event(dev, EV_KEY, KEY_A, 1);
+ litest_event(dev, EV_SYN, SYN_REPORT, 1);
+ litest_dispatch(li);
+ litest_assert_empty_queue(li);
+
+ /* not a repeat frame */
+ litest_event(dev, EV_KEY, KEY_LEFTALT, 1);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ litest_dispatch(li);
+ litest_assert_key_event(li, KEY_LEFTALT, LIBINPUT_KEY_STATE_PRESSED);
+
+ /* normal repeat frame, ignored */
+ litest_event(dev, EV_KEY, KEY_LEFTALT, 2);
+ litest_event(dev, EV_SYN, SYN_REPORT, 1);
+ litest_dispatch(li);
+ litest_assert_empty_queue(li);
+
+ /* not repeat frame */
+ litest_event(dev, EV_KEY, KEY_LEFTALT, 0);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ litest_dispatch(li);
+ litest_assert_key_event(li, KEY_LEFTALT, LIBINPUT_KEY_STATE_RELEASED);
+
+ /* special alt+printscreen repeat frame, *not* ignored */
+ litest_event(dev, EV_KEY, KEY_LEFTALT, 1);
+ litest_event(dev, EV_KEY, KEY_SYSRQ, 1);
+ litest_event(dev, EV_SYN, SYN_REPORT, 1);
+ litest_dispatch(li);
+
+ /* special alt+printscreen repeat frame, *not* ignored */
+ litest_event(dev, EV_KEY, KEY_LEFTALT, 0);
+ litest_event(dev, EV_KEY, KEY_SYSRQ, 0);
+ litest_event(dev, EV_SYN, SYN_REPORT, 1);
+ litest_dispatch(li);
+
+ /* Note: the kernel doesn't release the key combo until both keys are released
+ * and the order is reshuffled so we have alt down, sysrq down, sysrq up, alt up
+ */
+ litest_assert_key_event(li, KEY_LEFTALT, LIBINPUT_KEY_STATE_PRESSED);
+ litest_assert_key_event(li, KEY_SYSRQ, LIBINPUT_KEY_STATE_PRESSED);
+ litest_assert_key_event(li, KEY_SYSRQ, LIBINPUT_KEY_STATE_RELEASED);
+ litest_assert_key_event(li, KEY_LEFTALT, LIBINPUT_KEY_STATE_RELEASED);
+
+ litest_assert_empty_queue(li);
+}
+END_TEST
+
TEST_COLLECTION(keyboard)
{
/* clang-format off */
@@ -484,5 +539,7 @@ TEST_COLLECTION(keyboard)
litest_add(keyboard_leds, LITEST_ANY, LITEST_ANY);
litest_add(keyboard_no_scroll, LITEST_KEYS, LITEST_WHEEL);
+
+ litest_add_for_device(keyboard_alt_printscreen, LITEST_KEYBOARD);
/* clang-format on */
}
--
2.50.1

View file

@ -4,8 +4,8 @@
%global gitversion 58abea394
Name: libinput
Version: 1.28.901
Release: 3%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist}
Version: 1.28.902
Release: 1%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist}
Summary: Input device library
# SPDX
@ -19,9 +19,6 @@ Source2: commitid
Source0: https://gitlab.freedesktop.org/libinput/libinput/-/archive/%{version}/libinput-%{version}.tar.bz2
%endif
Patch0001: 0001-plugins-add-a-plugin-to-emulate-high-resolution-whee.patch
Patch0002: 0002-evdev-track-KEY_SYSRQ-frames-and-pass-them-even-as-r.patch
BuildRequires: git-core
BuildRequires: gcc
BuildRequires: meson
@ -159,6 +156,9 @@ intended to be run by users.
%changelog
* Thu Jul 17 2025 Peter Hutterer <peter.hutterer@redhat.com> - 1.28.902-1
- libinput 1.28.902
* Wed Jul 16 2025 Peter Hutterer <peter.hutterer@redhat.com> - 1.28.901-3
- Fix Alt+PrintScreen not working (#2379912)

View file

@ -1 +1 @@
SHA512 (libinput-1.28.901.tar.bz2) = b314517a96bff9674256dd095b11559a9c5a005c6c213fef188e4afdd433d9a3fc6557c7b565342e13a0f93a90679fb4d694076616eabe8d13506cda068be487
SHA512 (libinput-1.28.902.tar.bz2) = ddf3da8ffd8f3c2b782fbfd06ecff9371831b8737100be857607912bcc9c7899236c2cbd1acd977786b768194eddefbab43402d2c23a6a30d3183cd9ccecaffa