Commit graph

1180 commits

Author SHA1 Message Date
Peter Hutterer
08d7d5918f util: free the test parameters after the run
And also ensure we have the null-termination even if
MUNIT_TEST_MAX_PARAMS are given.

Fixes: 2996a66b37 ("util: add support for parametrized tests")
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/372>
2025-12-16 00:32:21 +00:00
Peter Hutterer
d5198d0e53 proto: add a link to the online protocol docs
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/371>
2025-12-16 09:27:41 +10:00
Peter Hutterer
756f74ec73 test: declare the need_frame check as part of the context
Reproducible with something that produces a frame event:

   // queues e.g. pointer motion + frame
   peck_eis_dispatch_until_stable()
   with_server(peck) {
       // process the motion only
   }
   peck_eis_dispatch_until_stable()

The second peck_eis_dispatch_until_stable() triggers an assertion
because we still have the unhandled frame event pending but need_frame
was reset to false.

Keep this as a field in peck so it remembers across invocations.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/369>
2025-12-15 05:29:54 +00:00
Peter Hutterer
55381623f2 test: fix logic error checking for capabilities
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/370>
2025-12-15 11:48:41 +10:00
Peter Hutterer
73ec8dee9f eis: allow pausing the device when it is emulating
The whole point of pausing a device is to terminate the client's ability
to send events.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/367>
2025-12-15 10:51:16 +10:00
Peter Hutterer
fe47a0a1f7 Unref frame events when discarding an empty frame
Otherwise we leak that frame event.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/366>
2025-12-12 16:20:03 +10:00
Peter Hutterer
26e671f192 Swap the object id logging order
This gives us a same-sized prefix for messages, making visual parsing of
logs a bit easier.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/366>
2025-12-12 16:20:03 +10:00
Peter Hutterer
2996a66b37 util: add support for parametrized tests
munit supports test parameters (char* only) but the setup is a big
awkward/impossible in C to define statically. So lets simply pass the
parameters as one NULL-terminated string list and require names to be
prefixed with an @. During the test setup we can split that list up into
multiple parameters and pass those to the munit setup where they're
accessible via another wrapper macro:

MUNIT_TEST_WITH_PARAMS(test_foo, "@x", "1", "2", "@y", "100", "200") {
   const char *x = MUNIT_TEST_PARAM("@x");
   const char *y = MUNIT_TEST_PARAM("@y");
}

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/365>
2025-12-03 14:51:55 +10:00
Peter Hutterer
d55da9466c meson.build: apply consistent indentation
Mostly whitespace changes, the non-whitespace ones are adding trailing
commas on last arguments and moving the closing ) into a separate line
for multiline function calls.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/364>
2025-11-06 10:56:01 +10:00
Hongfei Shang
3f48d11958 tools: fix print for touch up in demo client
Signed-off-by: Hongfei Shang <shanghongfei@kylinos.cn>
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/363>
2025-11-05 11:31:38 +08:00
Peter Hutterer
2821282dc9 libei: include math.h for fmod
For correctness only, looks like math.h is already pulled in from
elsewhere anyway.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/362>
2025-11-03 15:27:38 +10:00
Jason Gerecke
acff519ac3 tools: Support EIS_EVENT_DEVICE_READY in eis-demo-server
We move the calls to resume and start emulation of new devices into a
handler that gets called only once a device is ready. We also set the
EIS_FLAG_DEVICE_READY flag to inform libeis that we want to process
these ready events.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/346>
2025-10-17 13:38:47 +10:00
Peter Hutterer
39a222868f proto: add a device ready request
The protocol currently supports a ei_device.done event to notify
the ei client that the initial description of the device is complete.
For some future use-cases the client may need to futher negotiate
properties of the device. For example for tablet tools the client may
narrow down capabilities of the tool.

The sequence with the new request is thus e.g.
     -> ei_seat.device
     -> ei_device.name
     -> ei_device.interface
     -> ei_device.interface
     -> ei_device.done
     <- ei_device.ready
     -> ei_device.resumed

In libei the request is sent automatically on unref of
the DEVICE_ADDED event. This makes clients immediately compatible
and for the typical (future) use-case of device configuration. Said
configuration will likely be handled in response to the DEVICE_ADDED
event anyway.

In libeis, a new EIS_EVENT_DEVICE_READY event that is sent when the client
sends that same event on the protocol, informing the EIS implementation
that this device is ready. For clients that do not support that version
the event is emulated immediately after sending ei_device.done.

This requires a flag bit to be long-term maintainable. The typical
EIS implementation currently calls eis_device_add() immediately
followed by eis_device_resume(). This doesn't leave any room to
wait for the client's ei_device.ready request.

One backwards-compatible solution could be to buffer the
eis_device_resume() until the ei_device.ready has been received but this
is fraught with hairy corner cases, e.g. if the client is a receiver
context we would also have to buffer all events immediately sent to the
client.

So instead, we have a flag in the context and if set by the caller, we
change the internal behavior to match ei_device interface version 3.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/346>
2025-10-17 13:38:47 +10:00
Peter Hutterer
7141566924 doc: two doxygen typo fixes
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/361>
2025-10-17 13:30:48 +10:00
Jason Gerecke
a646a4c19b eierpecken: Have peck_disable_ei[s]_behavior actually disable things
The peck_disable_eis_behavior and peck_disable_ei_behavior functions
would incorectly *enable* behaviors when called with certain arguments
that cover multiple behaviors (e.g. PECK_EIS_BEHAVIOR_ACCEPT_ALL).
This commit modifies the logic to instead disable the behaviors.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/359>
2025-10-03 08:48:49 -07:00
Peter Hutterer
2671079754 doc: drop the special sha for the hugo theme, update hugo instead
The special sha is no longer needed, let's bump to a recent version of
hugo instead and that should make it all work nicely (for a while).

Updating hugo requires changing to hugo.toml and forcing mermaid to be
enabled, without those changes the build failed with
 `failed to extract shortcode: template for shortcode "mermaid" not found`

This reverts commit 5909717700

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/358>
2025-08-28 14:35:59 +10:00
Jan Beich
4f11112be0 eis: implement getting client PID for BSDs after 70cfc6eed2
src/libeis-socket.c:192:15: error: variable has incomplete type 'struct ucred'
  192 |         struct ucred ucred;
      |                      ^
src/libeis-socket.c:192:9: note: forward declaration of 'struct ucred'
  192 |         struct ucred ucred;
      |                ^
src/libeis-socket.c:194:65: error: use of undeclared identifier 'SO_PEERCRED'
  194 |         int rc = getsockopt(source_get_fd(client->source), SOL_SOCKET, SO_PEERCRED, &ucred, &len);
      |                                                                        ^

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/357>
2025-08-26 09:33:24 +02:00
Peter Hutterer
19b6453540 libei 1.5.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-08-26 11:25:18 +10:00
Peter Hutterer
cae398c132 test: add a test for delaying the ping/sync
For both the tests send two pings, with a keyboard event in between.
Where the ping is processed, fetch all the events first up front, and
process them one by one in the right order.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/340>
2025-08-25 13:36:18 +02:00
Peter Hutterer
6c50e2f8a0 test: add support for disabling behaviors on the ei/eis context
Historically the preference for testing was to enable a bunch of
specific behaviors and then leave that as-is for the test. This can be
painful for some events, in particular sync/ping that are used
internally by libei's implementation.

Testing those events requires us to match the implementation-defined
internal setup which is a pain. Much easier to add a function
to allow disabling a specific behavior at some point during the test

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/340>
2025-08-25 13:40:49 +10:00
Peter Hutterer
7667d1fcd8 test: make some behavior enabling more expressive
Remove the non-obvious +1/-1 and use the enum values instead. Then group
the two together better and remove an unnecessary separate handling of
the flag setting.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/340>
2025-08-25 12:45:11 +10:00
Jonas Ådahl
5e57b1ed5f ei: Expose ei_event_ref()
As with eis, expose ei_event_ref() as well, for consistency.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/340>
2025-08-21 17:08:53 +02:00
Jonas Ådahl
42b9a89371 eis: Expose eis_event_ref()
This makes handling prolonged synchronization sequences easier, as one
doesn't have to work around only being allowed to hold one reference.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/340>
2025-08-21 17:08:53 +02:00
Jonas Ådahl
8d86ada12d ei: Send sync done event on last event unref
This allows the application to hold the sync event for a while longer,
e.g. to ensure previous events from ei have passed through relevant
plumbing and reached their internally intended targets, which might
happen synchronously between each processed ei event.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/340>
2025-08-21 17:08:53 +02:00
Jonas Ådahl
1010cdff3c eis: Send sync done event on last event unref
This allows the application to hold the sync event for a while longer,
e.g. to ensure previous events from EIS have passed through relevant
plumbing and reached their internally intended targets, which might
happen synchronously between each processed EIS event.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/340>
2025-08-21 17:03:27 +02:00
Axel Karjalainen
525d55a532 docs: Fix issues and make some language clearer
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/344>
2025-08-14 00:07:09 +00:00
Axel Karjalainen
70c3348dfe docs: Extend summaries
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/344>
2025-08-14 00:07:09 +00:00
Axel Karjalainen
4d999849ee docs: Make the description of context types more generic
The protocol should be separate from any specific implementation's own
terms.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/344>
2025-08-14 00:07:09 +00:00
Axel Karjalainen
f3f69e3a96 doc: Correct meaning of ei_connection.disconnected
Closes https://gitlab.freedesktop.org/libinput/libei/-/issues/85

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/344>
2025-08-14 00:07:08 +00:00
Peter Hutterer
3b98946b9a eis: only send scroll/button capabilities if the client supports them
Commit a902d5dbd8 ("protocol: replace the capabilities enum with an interface list")
added automatic handling for button/scroll interfaces on the protocol
because the libeis C API didn't have those as separate interfaces yet.
Any EIS implementation with POINTER/POINTER_ABSOLUTE would always
announce BUTTON/SCROLL capabilities.

Later in commit e6954b76d3 ("eis: change the API to match the protocol interfaces closer")
the required C APIs were added but this handling was never removed so an
EIS implementation always replied with button/scroll capabilities even
where not set. Fix this by removing this automatic announcement.

Fixes: e6954b76d3 ("eis: change the API to match the protocol interfaces closer")
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/353>
2025-08-05 07:02:57 +00:00
Peter Hutterer
7347aeacd2 eis: only send interface versions that the client announced
Do not reply with interfaces that the client never requested.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/353>
2025-08-05 07:02:57 +00:00
Peter Hutterer
1faaacda6e eis: send the interface version for the scroll interface
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/353>
2025-08-05 07:02:57 +00:00
Axel Karjalainen
e3e143ea42 test: fix false fail by actually looking for unbound capability mask
The previous implementation of
`test_seat_bind_invalid_caps_expect_disconnection`
didn't follow the protocol specification and assumed that `0x1` was
invalid.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/354>
2025-08-05 02:02:38 +03:00
Ian Douglas Scott
500ad0510f test: Advertise scroll/button interfaces in test_connect_receive_seat
This test was checking for the capabilities for `EI_SCROLL` and
`EI_BUTTON`, but not advertising those interfaces initially. Presumably
this was unintentional, given there's no comment that it's intentionally
advertising some protocols but not others.

Also, should the test have failed to find the capabilities when it
didn't advertise the protocol to to start with? This change just fixes
the test, anyway.

This was causing the test to fail for `reis` CI in a proposed change in
https://github.com/ids1024/reis/pull/11.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/352>
2025-07-31 19:33:26 -07:00
Peter Hutterer
45c526bcc9 ei: indentation fix
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/351>
2025-07-24 11:07:32 +10:00
Peter Hutterer
297f95efac utils: add the etrace macro
Same as the existing trace but prints to stderr. And #include stdio so
we can use this file as-is instead of needing extra includes.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/351>
2025-07-24 11:07:32 +10:00
Peter Hutterer
0831303a70 test: change peck_new_context to take varargs
This makes peck_new_context() take variable arguments in the style
key, v1, v2... where each value is defined by the free-form key.

What we need right now is the mode of the context, so let's add that.
In the future we will add more configurable bits here.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/351>
2025-07-24 11:07:32 +10:00
Peter Hutterer
0488b4b4d0 test: expand peck_new() to take varargs
This enables us to pass various configuration into the peck context
in the future without having to update every single test that doesn't
need that particular configuration.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/351>
2025-07-24 11:07:32 +10:00
Peter Hutterer
55335b9030 libei: fix the docs for the various _unref functions
Copy/paste from ei_unref but none of the others will disconnect the
context.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/349>
2025-07-24 00:54:06 +00:00
Peter Hutterer
12237f19ea ei: don't use the connection until we have one
If we're in EI_STATE_BACKEND ei->connection is NULL, causing a segfault
if in this state we unref our ei context.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/350>
2025-07-18 13:26:01 +10:00
Jonas Ådahl
6194880aa9 libeis: remove leftover debug log
Fixes: 73e0e8d339 ("eis: add EI_EVENT_SYNC as opaque event to correctly schedule callbacks")
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/348>
2025-07-16 13:42:13 +10:00
Peter Hutterer
5567524ecc Swap accidental trailing comma for a semicolon
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/347>
2025-07-11 00:59:06 +00:00
Jason Gerecke
883a60d4e6 oeffis: Correct spelling errors in log messages
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/343>
2025-07-02 14:03:34 -07:00
Jason Gerecke
6aa4dc0c7e doc: Correct spelling errors in the code documentation
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/343>
2025-07-02 14:03:34 -07:00
Jason Gerecke
ac9b92bbae proto: Correct spelling issues in the protocol documentation
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/343>
2025-07-02 14:03:33 -07:00
David Redondo
70cfc6eed2 Make it possible to fetch the pid of a client in socket mode
This is useful to get some more info about clients that try to
connect.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/339>
2025-07-01 08:50:48 +02:00
Kacper Piwiński
54e71e6dd5 util: don't call function in macro argument
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/342>
2025-06-29 07:48:45 +00:00
Kacper Piwiński
1b11d10ff2 util: use already computed strlen
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/342>
2025-06-29 07:43:34 +00:00
Peter Hutterer
edc8ea045a eis: don't warn about EPIPE, just debug-log it
While it's not the friendliest way of a client to exit, we do need to
expect clients to disconnect any time and that shouldn't trigger
warnings, it's somewhat expected behavior.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/337>
2025-06-16 11:20:21 +10:00
Peter Hutterer
8cd2b01bfa test: expose the ei socket fd to tests
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/337>
2025-06-16 11:20:21 +10:00