mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-27 03:20:06 +01:00
tablet: delay initial proximity in event until we have a serial
If the tablet is already in proximity on startup, we used to immediately sent a proximity event. We can't fetch MSC_SERIAL from the kernel, so that tool always had a serial of 0, followed by events with the real serial. Since clients are supposed to use the serial for the tracking of tools, this is suboptimal. When the tablet is added, merely set the internal proximity flags. This way we wait until the first real event from the device (which includes the serial number) and convert that into a proximity event. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
07420eec05
commit
ebe02cb19e
2 changed files with 25 additions and 14 deletions
|
|
@ -1463,14 +1463,12 @@ tablet_check_initial_proximity(struct evdev_device *device,
|
|||
libevdev_get_event_value(device->evdev,
|
||||
EV_ABS,
|
||||
ABS_MISC);
|
||||
tablet->current_tool_serial =
|
||||
libevdev_get_event_value(device->evdev,
|
||||
EV_MSC,
|
||||
MSC_SERIAL);
|
||||
|
||||
tablet_flush(tablet,
|
||||
device,
|
||||
libinput_now(device->base.seat->libinput));
|
||||
/* we can't fetch MSC_SERIAL from the kernel, so we set the serial
|
||||
* to 0 for now. On the first real event from the device we get the
|
||||
* serial (if any) and that event will be converted into a proximity
|
||||
* event */
|
||||
tablet->current_tool_serial = 0;
|
||||
}
|
||||
|
||||
static struct evdev_dispatch_interface tablet_interface = {
|
||||
|
|
|
|||
|
|
@ -2006,6 +2006,8 @@ START_TEST(tool_in_prox_before_start)
|
|||
struct libinput *li;
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput_event *event;
|
||||
struct libinput_event_tablet_tool *tev;
|
||||
struct libinput_tablet_tool *tool;
|
||||
struct axis_replacement axes[] = {
|
||||
{ ABS_DISTANCE, 10 },
|
||||
{ ABS_PRESSURE, 0 },
|
||||
|
|
@ -2014,6 +2016,7 @@ START_TEST(tool_in_prox_before_start)
|
|||
{ -1, -1 }
|
||||
};
|
||||
const char *devnode;
|
||||
unsigned int serial;
|
||||
|
||||
litest_tablet_proximity_in(dev, 10, 10, axes);
|
||||
|
||||
|
|
@ -2028,17 +2031,27 @@ START_TEST(tool_in_prox_before_start)
|
|||
event = libinput_get_event(li);
|
||||
libinput_event_destroy(event);
|
||||
|
||||
litest_wait_for_event_of_type(li,
|
||||
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY,
|
||||
-1);
|
||||
event = libinput_get_event(li);
|
||||
libinput_event_destroy(event);
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
litest_tablet_motion(dev, 10, 20, axes);
|
||||
litest_tablet_motion(dev, 30, 40, axes);
|
||||
libinput_dispatch(li);
|
||||
event = libinput_get_event(li);
|
||||
tev = litest_is_tablet_event(event,
|
||||
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
||||
tool = libinput_event_tablet_tool_get_tool(tev);
|
||||
serial = libinput_tablet_tool_get_serial(tool);
|
||||
libinput_event_destroy(event);
|
||||
|
||||
litest_tablet_motion(dev, 30, 40, axes);
|
||||
libinput_dispatch(li);
|
||||
event = libinput_get_event(li);
|
||||
tev = litest_is_tablet_event(event,
|
||||
LIBINPUT_EVENT_TABLET_TOOL_AXIS);
|
||||
tool = libinput_event_tablet_tool_get_tool(tev);
|
||||
ck_assert_int_eq(serial,
|
||||
libinput_tablet_tool_get_serial(tool));
|
||||
libinput_event_destroy(event);
|
||||
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_TABLET_TOOL_AXIS);
|
||||
litest_assert_empty_queue(li);
|
||||
litest_event(dev, EV_KEY, BTN_STYLUS, 1);
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue