mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-11 07:00:29 +01:00
evdev: use the button down time for no-scroll middle button press event
When we get the release event within the timeout, we send a press + release event for the middle button. Rather than using the release event's timestamp for both, remember and use the button press timestamp. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
0784218081
commit
aaa7622933
3 changed files with 26 additions and 3 deletions
|
|
@ -442,6 +442,7 @@ evdev_button_scroll_button(struct evdev_device *device,
|
|||
if (is_press) {
|
||||
libinput_timer_set(&device->scroll.timer,
|
||||
time + DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT);
|
||||
device->scroll.button_down_time = time;
|
||||
} else {
|
||||
libinput_timer_cancel(&device->scroll.timer);
|
||||
if (device->scroll.button_scroll_active) {
|
||||
|
|
@ -451,7 +452,8 @@ evdev_button_scroll_button(struct evdev_device *device,
|
|||
} else {
|
||||
/* If the button is released quickly enough emit the
|
||||
* button press/release events. */
|
||||
evdev_pointer_notify_physical_button(device, time,
|
||||
evdev_pointer_notify_physical_button(device,
|
||||
device->scroll.button_down_time,
|
||||
device->scroll.button,
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
evdev_pointer_notify_physical_button(device, time,
|
||||
|
|
|
|||
|
|
@ -150,6 +150,8 @@ struct evdev_device {
|
|||
/* Currently enabled method, button */
|
||||
enum libinput_config_scroll_method method;
|
||||
uint32_t button;
|
||||
uint64_t button_down_time;
|
||||
|
||||
/* set during device init, used at runtime to delay changes
|
||||
* until all buttons are up */
|
||||
enum libinput_config_scroll_method want_method;
|
||||
|
|
|
|||
|
|
@ -35,15 +35,34 @@ START_TEST(trackpoint_middlebutton)
|
|||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
struct libinput_event *event;
|
||||
struct libinput_event_pointer *ptrev;
|
||||
uint64_t ptime, rtime;
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
/* A quick middle button click should get reported normally */
|
||||
litest_button_click(dev, BTN_MIDDLE, 1);
|
||||
msleep(2);
|
||||
litest_button_click(dev, BTN_MIDDLE, 0);
|
||||
|
||||
litest_assert_button_event(li, BTN_MIDDLE, 1);
|
||||
litest_assert_button_event(li, BTN_MIDDLE, 0);
|
||||
litest_wait_for_event(li);
|
||||
|
||||
event = libinput_get_event(li);
|
||||
ptrev = litest_is_button_event(event,
|
||||
BTN_MIDDLE,
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
ptime = libinput_event_pointer_get_time(ptrev);
|
||||
libinput_event_destroy(event);
|
||||
|
||||
event = libinput_get_event(li);
|
||||
ptrev = litest_is_button_event(event,
|
||||
BTN_MIDDLE,
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
rtime = libinput_event_pointer_get_time(ptrev);
|
||||
libinput_event_destroy(event);
|
||||
|
||||
ck_assert_int_lt(ptime, rtime);
|
||||
|
||||
litest_assert_empty_queue(li);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue