Commit graph

1180 commits

Author SHA1 Message Date
Peter Hutterer
62ae6f5edf ei: make ei_disconnect() public
Previously the only way to disconnect from the EIS implementation was
to call ei_unref() and release all resources. This makes it more
difficult for shared cleanup code - clients already have code in place
to deal with DEVICE_REMOVED, SEAT_REMOVED, etc. but that code has to
be triggered manually before ei_unref() is called.

OTOH where the server disconnects us, libei already unwound the state
so we would artificially generate these removed events, allowing the
client to clean up.

Make life easier for client by allowing them to ei_disconnect() and
get the benefits of our state unwinding. ei_disconnect() was already
used internally to disconnect on any error so this merely makes this
function public.

Closes #67

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/311>
2024-12-05 02:44:56 +00:00
Peter Hutterer
b33317cda0 util: Add the trace() debugging macro
Copied from libinput but pushed into util-macros with the color escape
codes expanded for simplicity.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/315>
2024-12-03 05:25:33 +00:00
Peter Hutterer
327dd4f8b1 test: fix string encoding in the python test bindings
The protocol encoding is the string including the null byte. The test
wrappers sent the right string length but only encoded strlen() bytes so
where we had a string that's a multiple of 4 long we ended up claiming
it's a byte longer than was on the wire.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/314>
2024-12-03 13:18:54 +10:00
Peter Hutterer
076e8bc670 proto: correct some documentation regarding ei_touchscreen
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/313>
2024-12-02 10:28:19 +10:00
Peter Hutterer
1f0cc83548 ei: declare struct ei_touch
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/313>
2024-12-02 10:28:19 +10:00
Peter Hutterer
247b6acd3c meson.build: allow disabling libei and libeis
This is primarily a development feature because it makes it easier to
develop a new feature for just one library without having to worry
about build errors in the other library (e.g. when new protocol parts
are added).

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/310>
2024-12-02 00:23:14 +00:00
Peter Hutterer
b3a4243924 test: make the c++ build test mirror the c build test
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/310>
2024-12-02 00:23:14 +00:00
Peter Hutterer
80bbcc67ed libei: fix an error message, spurious 'd'
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/312>
2024-11-29 12:27:48 +10:00
Peter Hutterer
11aa10393b tool: allow for touchscreen-only seat in the demo server
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/312>
2024-11-29 12:27:48 +10:00
Peter Hutterer
1cf06d0af6 tools: fix colorprint in the demo server
This ended up as multiple print calls, better to compile the lot into a
single print message so its output can be collected correctly by pytest.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/312>
2024-11-29 12:27:48 +10:00
Peter Hutterer
a491580fc0 test: improve debugging for failed event type comparisons 2024-11-27 02:13:53 +00:00
Peter Hutterer
37ea216424 test: print the line no for peck_ei(s)_assert_no_events 2024-11-27 02:13:53 +00:00
Peter Hutterer
d593127c18 Revert "util: silence out-of-bounds read warning"
(t < &start_test_function_section) is never true so this commit ended up
disabling the unit tests altogether. That may shut up -fanalyze but
is somewhat of a regression in functionality...

This reverts commit 22c94fd916.
2024-11-26 15:33:36 +10:00
Peter Hutterer
0770fec433 Drop black, switch to ruff format 2024-10-17 16:18:51 +10:00
Peter Hutterer
dbc06510a1 scanner: switch to using dataclasses
This drops one dependency that we're not fully using anyway. Except for
the per-attribute validators that can be done in __post_init() we're not
using attrs for anything that dataclasses cannot do.
2024-09-12 00:39:09 +00:00
Peter Hutterer
a5826424f1 util: correct the fd validity check
Unlikely but the fd returned may be 0
2024-09-11 12:27:38 +10:00
Peter Hutterer
96609f82a0 util: do an allocation null check in strstrip 2024-09-11 12:27:38 +10:00
Peter Hutterer
55fe9303fb oeffis: rewrite sender_name to make the analyzer happy
Technically we need to check allocation failure of sender after xstrdup
but in doing so we might as well xalloc it and copy chars over
one-by-one.

No functional changes.
2024-09-11 12:27:38 +10:00
Peter Hutterer
005c4ac493 util: use xalloc instead of calloc to avoid NULL checks 2024-09-11 12:27:38 +10:00
Peter Hutterer
bbc1f8de1c util: fix a leaking fd in a test 2024-09-11 12:27:38 +10:00
Peter Hutterer
e3091a1802 util: fix a comment to use the right decimal marker for english 2024-09-11 12:27:38 +10:00
Peter Hutterer
22c94fd916 util: silence out-of-bounds read warning
gcc -fanalyze complains because it doesn't know the __stop section is
always greater than the __start section so it complains that we're
eventually reading past our __start section. Let's silence that with a
simple check.
2024-09-11 12:26:59 +10:00
Peter Hutterer
ec031bc4bf test: add a few non-null checks to make the static analyzer happy 2024-09-11 12:26:40 +10:00
Peter Hutterer
bf03c56300 Add a few missing va_end
Found by gcc -fanalyze
2024-09-11 12:25:41 +10:00
Peter Hutterer
37cc857a52 doc: demote the socket backend in the documentation
The socket backend is useful for debugging and testing but not for real
user-cases where the fd negotiation should be handled by the caller
(e.g. passing it down through the portal). Let's demote the socket
backend in favour of the fd backend.

Related https://gitlab.freedesktop.org/libinput/libei/-/issues/63
2024-09-03 04:00:33 +00:00
Peter Hutterer
6230e187fd README: reword the blurb about short lived applications
This particular wording dates to when libei created devices and the EIS
implementation would ack/nack those devices. This isn't the case anymore
so let's reword this a bit.

Closes #62
2024-08-22 12:12:20 +10:00
Peter Hutterer
997b7c0f37 libei 1.3.0 2024-08-08 10:18:24 +10:00
David Redondo
cf4ab5e73f Allow passing a fd to ei-demo-client
Like in ei-debug-events
2024-08-08 09:55:43 +10:00
David Redondo
ebde54f3b3 ei-demo-client: Remove obsolote portal option 2024-08-08 09:54:13 +10:00
Peter Hutterer
9f82bbf344 test: add tests for multiple regions
Adds the test for
commit 0f81114544 ("Fix region check for devices with multiple regions")
2024-08-07 10:51:12 +10:00
Peter Hutterer
e411b85a33 Print the event type name for invalid events 2024-08-07 10:47:25 +10:00
Peter Hutterer
917b79f83e proto: clarify the ei_keyboard.modifier event a bit
This is an event in response to "something change the modifier state"
where "something" was not an ei_keyboard.key event on this interface.
Examples are NumLock on after resumed, a nonzero XKB group, etc.

Closes #57
2024-08-01 02:09:29 +00:00
Peter Hutterer
54dd4353df proto: remove ambiguous wording hunk from the interface_version event
This wording is confusing, see
https://gitlab.freedesktop.org/libinput/libei/-/issues/59#note_2501641

Remove the explicit mention of interfaces with client-side created
objects so we fall back to the default "client announces, server
confirms" which is all we need here anyway.
2024-08-01 02:09:29 +00:00
Peter Hutterer
2f8872676d proto: add an extra reference to the interface_version event
Just in case, so it's more obvious that those two negotiate each other.
2024-08-01 02:09:29 +00:00
Peter Hutterer
712e9513c6 protocol: correct false references to interface_version
This is the handshake_version request/event, not the
ei_connection.interface_version.
2024-08-01 02:09:29 +00:00
Peter Hutterer
798b0966de proto: clarify that the scale factor is a multiplication factor 2024-08-01 02:09:29 +00:00
Peter Hutterer
d6a8a5e94a proto: clarify that a client bug means ignored and/or disconnected 2024-08-01 02:09:29 +00:00
Peter Hutterer
362c4c392a proto: remove vestiges of ei_device.capability
This is now obsolete after [1]. The ei_device.interface event announces
which interfaces are available on the device so we don't need
documentation to say "it's a bug to send this request if the device
doesn't have the capability" since the client won't have the interface
to begin with.

Fixes: a902d5dbd8 ("protocol: replace the capabilities enum with an interface list")
2024-08-01 02:09:29 +00:00
Peter Hutterer
438140feb2 proto: correct the ei_device.interface documentation
Remove leftovers from when this was an ei_device.capability event
but since removed, see [1]. Instead make clear that this needs to be
one of the bound interfaces.

[1] a902d5dbd8 ("protocol: replace the capabilities enum with an interface list")
2024-08-01 02:09:29 +00:00
Peter Hutterer
0b2f46e1a2 proto: note that a touch without a region is a EIS bug 2024-08-01 02:09:29 +00:00
Peter Hutterer
a5dd5a5ee5 proto: fix a wrong interface reference: callback -> pingpong 2024-08-01 02:09:29 +00:00
Peter Hutterer
5331dc0bf2 proto: the keymap event is optional, clarify that
A device may not have a keymap in which case it just sends scancodes
hoping they'll be mapped to something sensible.
2024-08-01 02:09:29 +00:00
Peter Hutterer
b67cdba809 CI: avoid duplicate pipelines 2024-08-01 11:56:23 +10:00
David Redondo
e8a844355f oeffis: Make ConnectToEIS call async
A blocking call can be  problematic when done from inside Xwayland
to the compositor as the compositor could be doing a blocking X call
at the same time. In this instance we found it's likely to happen
because this call will happen shortly after the user accepted the
This is not a problem for the other calls because the portal API
is async for these via request response signalling.
2024-07-31 07:05:48 +00:00
Peter Hutterer
865d7152e0 util: replace a strncpy with a memcpy
We know exactly the lengths of everything involved here so let's use
memcpy. This way we don't need the stringop-truncation warning (a pragma
clang doesn't support anyway).
2024-07-29 05:15:53 +00:00
Peter Hutterer
3e2e43e352 ei-demo-client: use xkb_keymap_new_from_buffer()
This is the more correct approach since we get a sized buffer from the
server and people may use this as reference code in their implementation.
Technically we cannot expect a true zero-terminated string from EIS.

Unfortunately this means we need to work around
libxkbcommon#307 to strip trailing zeroes from the buffer if any exist.
2024-07-29 14:54:31 +10:00
Peter Hutterer
a924888f0f ei-demo-client: use mmap to read the keymap
Closes #55
2024-07-29 14:53:35 +10:00
Peter Hutterer
6ea468c823 util/memfile: use MAP_SHARED to create the map
Using MAP_PRIVATE means copy-on-write so our data written into the map
immediately disappears again. This leads to a empty string when sending
a keymap to a client.
2024-07-29 14:48:34 +10:00
Peter Hutterer
dc153c50ed util/memfile: include stddef for size_t 2024-07-29 14:48:34 +10:00
Peter Hutterer
c4ac084159 util/memmap: add a helper wrapper around mmap
Makes this easier to use with our unref functions.
2024-07-29 14:48:34 +10:00