From c76e05a0aed9a26495409e682e15950ba130fc02 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 19 Aug 2025 15:05:32 +1000 Subject: [PATCH] plugin: reset the filtered frame after sending it with buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our filtered frame (frame without any button events) that gets passed down to here may include relative motion or other events. Once we use that frame to prepend the button event we need to reset it so we don't cause duplicate motion and/or events with zero delta timestamps. With the the previous code we got two identical frames: 42: event25: plugin button-debounce - 0.360 EV_MSC MSC_SCAN 30 ... event25: plugin button-debounce - 0.360 EV_KEY BTN_RIGHT 1 ... event25: plugin button-debounce - 0.360 EV_REL REL_X -7 ... event25: plugin button-debounce - 0.360 EV_REL REL_Y -7 ... event25: plugin button-debounce - 0.360 ----------------- EV_SYN ----------------- +8ms ... Plugin:button-debounce - debounce state: DEBOUNCE_STATE_IS_UP → DEBOUNCE_EVENT_OTHERBUTTON → DEBOUNCE_STATE_IS_UP ... Plugin:button-debounce - debounce state: DEBOUNCE_STATE_IS_UP → DEBOUNCE_EVENT_PRESS → DEBOUNCE_STATE_IS_DOWN_WAITING ... event25: plugin evdev - 0.360 EV_MSC MSC_SCAN 30 ... event25: plugin evdev - 0.360 EV_REL REL_X -7 ... event25: plugin evdev - 0.360 EV_REL REL_Y -7 ... event25: plugin evdev - 0.360 EV_KEY BTN_RIGHT 1 ... event25: plugin evdev - 0.360 ----------------- EV_SYN ----------------- +0ms ... Queuing event25 POINTER_MOTION +0.000s -7.00/ -7.00 ( -7.00/ -7.00) ... event25 - middlebutton state: MIDDLEBUTTON_IDLE → MIDDLEBUTTON_EVENT_R_DOWN → MIDDLEBUTTON_RIGHT_DOWN, rc 1 ... event25: plugin evdev - 0.360 EV_MSC MSC_SCAN 30 ... event25: plugin evdev - 0.360 EV_REL REL_X -7 ... event25: plugin evdev - 0.360 EV_REL REL_Y -7 ... event25: plugin evdev - 0.360 EV_KEY BTN_RIGHT 1 ... event25: plugin evdev - 0.360 ----------------- EV_SYN ----------------- +0ms ... Queuing event25 POINTER_MOTION +0.000s -nan/ -nan ( -7.00/ -7.00) event25 POINTER_MOTION +0.360s -7.00/ -7.00 ( -7.00/ -7.00) event25 POINTER_MOTION 2 +0.360s -nan/ -nan ( -7.00/ -7.00) The 0ms delta caused a -nan in the custom pointer accel but even without that bug the pointer would've jumped more than it should. Closes #1172 (cherry picked from commit 4d317eae17f277f35f796dd013a026407a1cd653) Part-of: --- src/libinput-plugin-button-debounce.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libinput-plugin-button-debounce.c b/src/libinput-plugin-button-debounce.c index 1062a34c..aff1752e 100644 --- a/src/libinput-plugin-button-debounce.c +++ b/src/libinput-plugin-button-debounce.c @@ -264,6 +264,11 @@ debounce_notify_button(struct plugin_device *device, libinput_plugin_prepend_evdev_frame(device->parent->plugin, device->device, frame); + + /* If we used the original frame, reset it to avoid re-sending any + * non-button events that may be present in this frame */ + if (button_frame == NULL) + evdev_frame_reset(frame); } static void