Commit graph

601 commits

Author SHA1 Message Date
Peter Hutterer
721426a1be test: highlight the gesture state machine log messages in yellow
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
2024-09-12 15:24:47 +10:00
Peter Hutterer
0ec0a4212a test: make litest_wait_for_event_of_type auto-terminating
Wrap this in a macro so we cannot forget to pass -1

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
2024-09-12 12:37:55 +10:00
Peter Hutterer
d0bec3843a test: make litest_drain_events_of_type auto-terminating
Wrap this in a macro so we cannot forget to pass -1

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
2024-09-12 12:37:50 +10:00
Peter Hutterer
47f94633fe test: remove some old compat code for kernel<4.5
Kernel 4.5 and libevdev 1.5 were released in 2016, this code is no
longer necessary.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/986>
2024-03-18 23:02:05 +00:00
Peter Hutterer
3d246ef248 test: remove a workaround for libevdev 1.2 and earlier
libevdev 1.3 was released in 2014.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/986>
2024-03-18 23:02:05 +00:00
Peter Hutterer
34f86489a8 Revert "test: allow for substring matching in the various --filter- arguments"
Substring matching means it's impossible to select filters that are
substrings of others, making it too painful to test one specific filter.

This reverts commit a524cf9761.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/984>
2024-03-18 16:25:47 +00:00
Peter Hutterer
c775c23121 test: slightly increase the finger switch timeout wait
In touchpad_2fg_scroll_return_to_motion we sometimes fail because the
timeout is too close to the actual timeout expiry, creating a race
condition on whether the scroll stop event (triggered by the gesture
end) is sent before or after the timeout expiry.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/984>
2024-03-18 16:25:47 +00:00
Peter Hutterer
9c69152428 Move mkdir_p into a utility header
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/984>
2024-03-18 16:25:47 +00:00
Peter Hutterer
3644372696 test: add helpers for checking (negative) errnos
This way we get to see the actual error when it happens.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/984>
2024-03-18 16:25:47 +00:00
Joshua Goins
beca998122 tablet: add API for relative dials
Some tablets such as those in the XP-PEN PRO series use "dials" which
are actually scrollwheels and emit EV_REL events. These should not be
emulated as rings (which are absolute) so we must expose them as a new
tablet event.

Adds LIBINPUT_EVENT_TABLET_PAD_DIAL that work largely identical as our
high-resolution wheel events (i.e. the values are in multiples or
fractions of of 120). Currently supports two dials.

This is a lot of copy/paste from the ring axes because the interface is
virtually identical. The main difference is that dials give us a v120
value in the same manner as our scroll axes.

Notes:
- REL_DIAL is mutually exclusive with REL_WHEEL, we assume the kernel
  doesn't (at this point) give us devices with both. If this changes for
  devices with three dials (wheel + hwheel + dial) we need to add code
  for that.
- REL_DIAL does not have a high-resolution axis and we assume that any
  device with REL_WHEEL_HI_RES will also have REL_HWHEEL_HI_RES (if the
  second wheel exists).
- With dials being REL_DIAL or REL_WHEEL there is no possibility of
  detecting a finger release (the kernel does not route EV_RELs with a
  value of zero). Unless this is implemented via a side-channel - and it
  doesn't look like any hardware that supports dials does that - we
  cannot forward any information here. So unlike absolute rings we
  cannot provide a source information here.

Closes #600

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/967>
2024-02-20 02:49:05 +00:00
Peter Hutterer
c5f808ac2e test: debug print the events we're draining 2024-01-22 01:21:29 +00:00
Peter Hutterer
3fb876a49d test: expand the tablet mode switch test to check for fake key releases
If a key is still down when the tablet mode switch goes on, make sure we
release the key before the switch goes in effect.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-07-17 09:32:24 +10:00
Peter Hutterer
44de3ff367 test: add an extra override hook for tablet motion
Currently unused but it complements the existing override handlers.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-06-07 09:23:05 +10:00
Peter Hutterer
160b062454 test: change tablet coords to doubles and pass the pointer through
All other motion/touch/... coords are already doubles so let's follow
suite here. And passing a pointer into the custom handlers
means we can modify x/y slightly and return false, leaving the rest up
to the generic event handling code.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-06-07 09:23:05 +10:00
José Expósito
8a6ca3c1c5 sparse: make some variables static
When compiling with Sparse enabled:

	$ CC=cgcc meson builddir

Fix warnings about variables that should be made static.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-11-23 21:57:28 +00:00
Peter Hutterer
395d12d634 util: auto-declare the element variable in ARRAY_FOR_EACH
All cases we have in our code base have an otherwise unused variable to
loop through the array. Let's auto-declare this as part of the loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-09 10:16:07 +10:00
Peter Hutterer
878d00b0e9 test: add tip down/up helper functions
Add two helper functions that set/unset BTN_TOUCH together with the
specified axes and switch all tests over.

Devices can override the tip down/up sequence.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-11-24 06:17:31 +00:00
José Expósito
b6a944bb80 wheel: ignore initial small scroll deltas
Mice with high-resolution support can generate deltas when the finger is
put on the wheel or when the user tries to click the wheel.

To avoid sending involuntary scroll events, add an extra state the the
wheel state machine to accumulate scroll deltas.
While the accumulated scroll is lower than a certain threshold, ignore
them until the threshold is reached.

Since no finish event is sent by the mouse, reset the state machine
after a period of scroll inactivity.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-11-08 18:00:46 +01:00
José Expósito
e0aa946e39 test: add kernel bugs to log handler
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-09-27 22:43:22 +00:00
Peter Hutterer
6bb02aaf30 High-resolution scroll wheel support
Starting with kernel v5.0 two new axes are available for high-resolution wheel
scrolling: REL_WHEEL_HI_RES and REL_HWHEEL_HI_RES. Both axes send data in
fractions of 120 where each multiple of 120 amounts to one logical scroll
event. Fractions of 120 indicate a wheel movement less than one detent.

This commit adds a new API for scroll events. Three new event types that encode
the axis source in the event type name and a new API to get a normalized-to-120
value that also used by Windows and the kernel (each multiple of 120 represents
a logical scroll click).

This addresses a main shortcoming with the existing API - it was unreliable to
calculate the click angle based on the axis value+discrete events and thus any
caller using the axis value alone would be left with some ambiguity. With the
v120 API it's now possible to (usually) calculate the click angle, but more
importantly it provides the simplest hw-independent way of scrolling by a
click or a fraction of a click.

A new event type is required, the only way to integrate the v120 value
otherwise was to start sending events with a discrete value of 0. This
would break existing xf86-input-libinput (divide by zero, fixed in 0.28.2) and
weston (general confusion). mutter, kwin are unaffected.

With the new API, the old POINTER_AXIS event are deprecated - callers should use
the new API where available and discard any POINTER_AXIS events.

Notable: REL_WHEEL/REL_HWHEEL are emulated by the kernel but there's no
guarantee that they'll come every accumulated 120 values, e.g. Logitech mice
often send events that don't add up to 120 per detent.

We use the kernel's wheel click emulation instead of doing our own.

libinput guarantees high-resolution events even on pre-5.0 kernels.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-31 08:45:01 +02:00
José Expósito
427c855d21 test: refactor litest_assert_event_type logic
Extract the logic in litest_assert_event_type to a generic function,
litest_assert_event_type_is_one_of, that takes a variable number of
expected event types.

Refactor, no functional changes.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-31 14:42:15 +10:00
Peter Hutterer
b925b55634 test: use MESON_TESTTHREADS to determine the number of jobs
meson uses MESON_TESTTHREADS to determine the number of parallel test
jobs. Since our main test suite cannot be run in parallel anyway, use
that same variable in litest to determine how many jobs we should fork
off.

In the CI pipeline, we can use FDO_CI_CONCURRENT to pass that down so we
don't end up running a billion jobs on a test runner.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-03 22:14:29 +00:00
luokai
87447a0ee9 using secure functions safe_strdup
Signed-off-by: luokai <l18674732394.com>
2021-06-15 11:27:29 +08:00
José Expósito
9b024c6928 gestures: add quick hold implementation
When 1 or 2 fingers are used to hold, use a faster timer to make the
"hold to stop kinetic scrolling" user interaction feel more immediate.

Also handle double tap and tap and drag interations to send only one
hold gesture instead of two.

Holding with 3 or 4 fingers remains the same to try to avoid callers
missusing hold gestures to build their own tap implementation.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-06-09 01:18:58 +00:00
José Expósito
a18d9d3de4 tests: optionally hold in gesture test functions
Add an extra parameter to the common gesture test functions to allow to hold
before performing the gesture.

This parameter will be used by the hold tests allowing to share the code.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-06-09 01:18:58 +00:00
José Expósito
b6b15fa304 libinput: add hold gesture public API and tool support
Add hold gestures to the public API and the private functions to notify them.
Also add hold gestures to debug-events and debug-gui.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-06-09 01:18:58 +00:00
Peter Hutterer
1d9cdf76a5 test: push/pop event frames around three-touch movements
Without this, each finger movement happens in a different evdev event frame.
Since we average deltas for gestures, this messes with the expected data.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Peter Hutterer
dee0e5e725 test: simplify the helper for moving three touches at the same time
There's no test case where we need to do something immediately after the last
event so we might as well do everything in the same loop.

This also fixes a bug where the first movement would usually get swallowed.
Test cases in general put the finger down at x/y, then move them to some other
position. We'd expect the first event in a loop to happen at x+n/y+n, not at
x/y again.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Peter Hutterer
5129d178b3 test: fix debugging messages for gesture begin event
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Konstantin Kharlamov
3d3d9b7f69 treewide: get rid of tmp argument in list_for_each_safe
Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2021-03-02 09:10:35 +03:00
Peter Hutterer
e96852ac37 test: add test cases for 2/3 finger movement after tap
We have two behaviors here:
- tap + 2fg -> scrolling
- tap + 1fg move + 2f down -> dragging

Let's document this. The 3fg case only has one situation, so let's test that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-15 18:03:34 +10:00
Peter Hutterer
06ef838b5b test: drop the needless base event conversion
This was just there to avoid unused variable warnings but the simpler approach
to that is to just not assign a variable in the first place.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-15 18:03:34 +10:00
Peter Hutterer
b8d4197697 test: print the event type on mismatch
We already have a helper function for this, let's use it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-15 17:34:51 +10:00
satrmb
a91ecbde74 touchpad: stretch the tap-and-drag timeout a bit depending on finger count
Some users reported problems triggering multi-finger tap-and-drag,
with reliability decreasing as the finger count increased.
This is plausible because they may shift towards moving the whole hand
up and down, which obviously takes more time than just a finger.

Signed-off-by: satrmb <10471-satrmb@users.noreply.gitlab.freedesktop.org>
2021-02-15 05:46:46 +00:00
Peter Hutterer
d3115f4875 test: drop the custom group names
The group names are forced by check (they are called suite names there) but
for our test suite they provide very little benefit. Much easier to just
use the filename a test is in as group name.

This removes the pure substring match for --filter-group, it's now fnmatch
only. group names are short enough that the typing isn't an issue and we don't
want to run tests twice (e.g. 'pad' is also in 'touchpad').

This patch caused #574 until it got fixed in d838e3a3a4

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-12 15:24:15 +10:00
Peter Hutterer
4422e95747 test: don't require root to list tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-05 16:04:54 +10:00
weizhixiang
2ed0f24e20 check return value for libudev/udev_device_get_action
Signed-off-by: weizhixiang <1138871845@qq.com>
2021-01-06 17:46:14 +08:00
Torstein Husebø
18c9265224 treewide: fix typos
Signed-off-by: Torstein Husebø <torstein@huseboe.net>
2020-12-16 22:08:23 +01:00
Peter Hutterer
d35f1319de test: set the elan test device to always double up on tool bits
This is the device from
https://gitlab.freedesktop.org/libinput/libinput/-/issues/259 which sets
BTN_TOOL_PEN in addition to the real tool. Integrate this into the test device
proper so it always does this to catch various outliers.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-22 17:35:41 +10:00
Peter Hutterer
df2759706f test: auto-assign the tool type for tablet tests
The current tool type test merely sends BTN_TOOL_RUBBER (and others) manually
and expects libinput to do the right thing. This only tests the perfect
sequence but not test weird devices that behave differently on a tool type
switch.

So let's fix this by setting the tool type as property on the libinput test
device itself, and then emulate the tool switch through litest.
For special devices this will need extra callbacks, this is just the initial
framework to handle those buttons.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-22 17:35:41 +10:00
Peter Hutterer
2e25741061 test: grab the device before any lid or tablet mode switches
Putting an EVIOCGRAB on the device before sending those events means no-one
else sees those events - particularly upower. This means no-one else knows the
lid is on or off and thus we never blank the screen (or suspend/shut down but
those are inhibited anyway).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-07 18:51:33 +10:00
Peter Hutterer
86946342fb test: store the list of open file descriptors in the litest context
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-07 18:51:33 +10:00
Peter Hutterer
52d6398753 test: use litest_destroy_context() for test-suite contexts
Symmetrical to litest_create_context(), this allows us to store special data
in that context that we have access to during the tests.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-07 18:51:33 +10:00
Peter Hutterer
9bb8133486 test: inhibit shutdown and suspend while the tests are running
We test lid switch events which are independently handled by Upower. Let's
make sure nothing else can tell logind to suspend or shut down while we're
running.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-07 18:51:33 +10:00
Peter Hutterer
727dc44b04 meson.build: use install_subdir() to install the quirks files
This removes the need to check whether the files were added in meson.build but
requires litest to traverse the source dir now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-17 07:52:00 +00:00
Peter Hutterer
d724dc060b Replace strneq() with strstartswith() for variable prefixes
Leaving in-place all those where we know the length of the prefix, but
replacing all those where we were calling strlen on the prefix.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-17 07:52:00 +00:00
Peter Hutterer
bd7b91065b evdev: warn if our event processing lags by 10ms or more
Take a snapshot of the time every 10 libinput_dispatch() calls. During event
processing, check if the event timestamp is more than 10ms in the past and
warn if it is. This should provide a warning to users when the compositor is
too slow to processes events but events aren't coming in fast enough to
trigger SYN_DROPPED.

Because we check the device event time against the dispatch time we may get
warnings for multiple devices on delayed processing. This is intended, it's
good to know which devices were affected.

In the test suite we need to ignore the warning though, since we compose the
events in very specific ways it's common to exceed that threshold
(particularly when calling litest_touch_move_to).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-05-13 06:21:27 +00:00
Peter Hutterer
2ff0c3427d test: fix the lookup for the timer offset warnings
This was changed in 5e25bdfb03 but the litest
message lookup wasn't changed. Let's do that now and change to a generic
wording we can re-use for other messages.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-05-13 06:21:27 +00:00
Peter Hutterer
281ecf10d1 udev: don't use IMPORT+=
IMPORT really only supports == and != and for a short while udevd warned about
this before that warning was reverted again.

Where anything else is used, it falls back to ==. systemd upstream rules all
use a single = though, so let's stick with that to be consistent, even if it
is technically wrong (udevd will warn about this in debug mode).

See the long discussion in systemd upstream for details:
https://github.com/systemd/systemd/issues/14062

Fixes #461

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-30 00:35:43 +00:00
Peter Hutterer
0dcb02d369 test: add a test case for checking EVDEV_ABS overrides
Problem: it's still not a 100% check because the way real udev handles the
EVDEV_ABS overrides ignores any that are set through udev properties only. So
we manually have to trigger the keyboard builtin for our test device which
can give us false positives (e.g. it wouldn't have detected #424). But still,
it'll alert us if the actual overridden values are different to what we
expect.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-12 21:22:01 +10:00