Commit graph

1180 commits

Author SHA1 Message Date
Peter Hutterer
98e445ebdb test: add ability to capture logs
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/337>
2025-06-16 11:20:21 +10:00
Peter Hutterer
dbeff9a90d test: add a bunch of strv helpers
Taken from libinput

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/337>
2025-06-16 11:20:21 +10:00
Peter Hutterer
efdc58e094 test: remove an unused function
Obsolete since 479bda259a ("Purge libreis from the repo")

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/338>
2025-06-13 16:49:03 +10:00
Jason Gerecke
50ff529a76 Fix MIT license header text
Corrects an issue where a wild search-and-replace mangled the license
texts on protocol implementations.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/335>
2025-05-29 23:07:48 +00:00
Jason Gerecke
6c5b486306 scanner: Avoid trailing full stops in regex search for protocol names
Continue to find nested ei_foo.bar.baz but avoid including a trailing
full stop, if it exists.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/336>
2025-05-29 14:35:19 -07:00
Jonas Ådahl
ee27dd5c92 ei-device: Don't leak fd when receiving the keymap
The ei_keymap dups the file descriptor, so lets close the one we
received from the demarshaller.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/334>
2025-05-22 22:43:35 +02:00
Peter Hutterer
851f935fe1 tools: print missing event types in the demo client
Instead of aborting, print something useful

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/332>
2025-05-19 11:34:54 +00:00
Peter Hutterer
2556ad38c6 tools: handle EI_EVENT_SYNC in the demo client
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/332>
2025-05-19 11:34:54 +00:00
Peter Hutterer
b2484c00d0 CI: bump to Fedora 42 and latest ci-templates
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/333>
2025-05-19 16:11:49 +10:00
Peter Hutterer
daba46a2ae eis: if a client is slow, queue up messages for future delivery
If a receiver client stops calling ei_dispatch for a while eventually
we fill up the send buffer, causing messages to be quietly dropped.
When the client resumes the message stream resumes with whatever we send
next but that can leave the client in an inconsistent state.

deskflow hit this in the server-side where our event sequence of pointer
motion+frames eventually filled up the buffer, causing
eis_device_stop_emulating() to be silently dropped. On the next
InputCapture sequence eis_device_start_emulating() was sent to an
already emulating client (as seen by the client).

This patch adds a secondary queue, if we fail to send a message with
EAGAIN queue it up and flush that queue whenever the next message is
sent. Meanwhile any newly added messages go straight into that queue.

The caveat here: a nonresponding client will eventually trigger OOM,
there is no upper limit on the messages yet

This is the libeis version of
commit 69e973e6b3 ("ei: queue unsent messages for later delivery if our buffer is full")

Closes: #79
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/331>
2025-05-02 15:40:47 +10:00
Peter Hutterer
daf0b24665 test: add a test for multiple start/stop emulating events
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/331>
2025-05-02 15:40:47 +10:00
Peter Hutterer
247a3d49d7 ei: print the sequence number on error for a start_emulating event
This may help debugging which sequence triggered an error.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/330>
2025-05-02 05:39:52 +00:00
Eric Long
e147d4311f test: increase protocol-test-valgrind timeout
Currently libei's valgrind test setup has 100x timeout (3000s), but the
standalone protocol-test-valgrind still has 30s timeout, which is not enough
for RISC-V hardware. On Milk-V Pioneer (SG2042) it takes ~70s to complete. In
addition, `kill_gently` sends SIGKILL before the process terminates and fails
the test.

Bump protocol-test-valgrind timeout to 300s and increase timeout between kill
signals to 3s to solve the issue.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/329>
2025-04-11 15:32:20 +08:00
Peter Hutterer
9e0413cbc7 libei 1.4.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-04-01 13:52:48 +10:00
Peter Hutterer
962863cbc4 scanner: ensure 'since' doesn't exceed the interface version
See https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/327

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/328>
2025-03-31 10:00:19 +10:00
Peter Hutterer
b0deafc641 scanner: convert the 'version' and 'since' arguments to int
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/328>
2025-03-31 10:00:05 +10:00
Ian Douglas Scott
fa21d765a1 proto: Fix version for ei_touchscreen
Fixes: b1c1c5d579 ("Add the ei_touchscreen.cancel event and ei_touch_cancel()")
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/327>
2025-03-31 09:11:56 +10:00
Corentin Noël
eda5b90760 meson.build: Use the correct name for the libraries overrides
The libraries are actually suffixed with the API number, use the same value as
their pkgconfig basenames.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/326>
2025-03-26 15:33:34 +01:00
Peter Hutterer
5d6d8e6590 libei 1.4.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-02-12 13:05:24 +10:00
Peter Hutterer
d25ceaff98 libei 1.4 RC1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-02-03 13:33:25 +10:00
Peter Hutterer
76845ecdfe Reformat for ruff 0.9
New formatting rules, apparently.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/325>
2025-02-03 13:17:34 +10:00
Peter Hutterer
fb85496aa3 pre-commit: update to the latest version of our hooks
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/325>
2025-02-03 13:17:12 +10:00
Peter Hutterer
6068f3b14c CI: drop the python-black naming from the ruff job
Fixes: 0770fec433 ("Drop black, switch to ruff format")
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/325>
2025-02-03 13:13:59 +10:00
Peter Hutterer
6bbb3c5979 proto: fix a trailing whitespace
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/323>
2025-02-03 12:05:56 +10:00
Erik Jensen
1152c038ee Specify MODIFIERS to be sent for any state change.
Updates protocol and API documentation to specify that the modifiers
event should be sent by the EIS implementation every time the modifier
or group state changes, including when the change is triggered by key
events on the emulated keyboard.

The previous approach of expecting the client to track modifier state
using xkb_state_update_key() for injected keys resulted in multiple
opportunities for the client and server to get out of sync (both due to
unavoidable race conditions and due the client not having access to the
complete state used by the server to calculate state changes), with no
way for the client to ensure it had a correct modifier map short of
unbinding and rebinding the seat.

The new approach allows the client to track state solely by applying
modifiers events with xkb_state_update_mask(), simplifying client
implementation. Because the event is sent for all changes, the client
can use ei_connection.sync / ei_ping() to ensure that it has received
the latest state incorporating all key requests sent prior to the sync
request (along with any externally-caused modifier state changes that
may have occured up to the time the sync message was received).

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/318>
2024-12-18 04:41:11 +00:00
Peter Hutterer
564f14a739 ei: add EI_EVENT_SYNC as opaque event to correctly schedule callbacks
See the corresponding eis commit for details.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/316>
2024-12-18 04:30:01 +00:00
Peter Hutterer
73e0e8d339 eis: add EI_EVENT_SYNC as opaque event to correctly schedule callbacks
This event is required to fix an issue with the current
ei_callback.done handling in libeis: previously we would imediately send
the ei_callback.done upon receiving ei_connection.sync from the client.
This results in incorrect behavior as we may have events in the queue
(and/or pending a frame) that the EIS implementation hasn't seen yet.
For example a client sending:
- ei_pointer.motion
- ei_connection.sync
- ei_device.frame
- ei_connection.sync

Will queue a motion + frame event on the EIS side during eis_dispatch()
but immediately receive done events for both sync requests.

This could be handled purely internally by keeping the sync event in the
queue but hidden to the caller - and automatically calling done when
it's that events turn, i.e. something like:

```
  struct eis_event *eis_get_event(struct eis) {
      struct eis_event *e = first_event(eis);
      if (e == EIS_EVENT_SYNC) {
           eis_callback_send_done(e);
           eis_event_unref(e);
           e = next_event(eis);
      }
      return e;
  }
```

but that opens us up to a set of potential bugs detailed in
https://gitlab.freedesktop.org/libinput/libei/-/issues/71#note_2694603

So let's go the easy route by having a new event type that does nothing
other than eis_event_unref() in the EIS implementation. This way we can
queue the event and have everything behave in-order and as expected.

Closes #71

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/316>
2024-12-18 04:30:01 +00:00
Peter Hutterer
971013429d test: add a test for sync events during frames
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/316>
2024-12-18 04:30:01 +00:00
Peter Hutterer
e40796402b eis: add eis_ping() and the matching EIS_EVENT_PONG
Identical to "ei: add ei_ping() and the matching EI_EVENT_PONG" but for
libeis.

This wraps around ei_connection.ping to allow a C API user to add
synchronization points.

Closes #69

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/316>
2024-12-18 04:30:01 +00:00
Peter Hutterer
a278c7b371 ei: add ei_ping() and the matching EI_EVENT_PONG
This wraps around ei_connection.sync to allow a C API user to add
synchronization points.

Closes #69

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/316>
2024-12-18 04:30:01 +00:00
Peter Hutterer
2cc5e56e28 eis: revamp the internal sync callback
Identical to "ei: revamp the internal sync callback" but for libeis.

In prep work for exposing some of this to the caller, this adds a new
object that carries the our callbacks including the user data (if any).
This is an internal system only and is only used in the handshake
implementation where we don't have userdata anyway.

The new approach is: the callback has an object with a done() and
destroy() callback and the user data, done() is called when we receive
the message from the protocol, destroy() on destroy regardless whether
we got done() first.

This allows a caller to clean up user data even where the callback was
not triggered because we got disconnected first.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/316>
2024-12-18 04:30:01 +00:00
Peter Hutterer
95eb3c4bb3 ei: revamp the internal sync callback
In prep work for exposing some of this to the caller, this adds a new
object that carries the our callbacks including the user data (if any).
This is an internal system only and is only used in the handshake
implementation where we don't have userdata anyway.

The new approach is: the callback has an object with a done() and
destroy() callback and the user data, done() is called when we receive
the message from the protocol, destroy() on destroy regardless whether
we got done() first.

This allows a caller to clean up user data even where the callback was
not triggered because we got disconnected first.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/316>
2024-12-18 04:30:01 +00:00
Peter Hutterer
91e0b8961b doc: specifically mention that unknown events must be unref'd
And document the event type enums as non-exhaustive.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/322>
2024-12-17 16:00:59 +10:00
Peter Hutterer
3c88c0d3b2 tools/demo-server: note that aborting on unknown events is bad
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/322>
2024-12-17 15:59:02 +10:00
Peter Hutterer
9c35a57cfe doc: fix some linewrapping issues
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/322>
2024-12-17 15:59:02 +10:00
Peter Hutterer
b1c1c5d579 Add the ei_touchscreen.cancel event and ei_touch_cancel()
In the protocol it's a new request/event that is sent instead of the
touch up event.

In the library this is implemented as ei_touch_cancel() which
transparently sends cancel() or up depending on the EIS implementation
support. This is mirrored for the EIS implementation.

Where touch cancel is received as an event it is presented
as EI_EVENT_TOUCH_UP with an ei_event_touch_is_cancel() flag to
check if it was a cancel. This is required for backwards compatbility,
we cannot replace the TOUCH_UP event with a TOUCH_CANCEL event without
breaking existing callers. To add a new event type we would need clients
announcing support for those event types but that's an effort that's
better postponed until we have a stronger need for it (see #68).

Closes #60

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/308>
2024-12-17 15:12:56 +10:00
Peter Hutterer
739ea0f357 protocol: fix the description summary for the touch events
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/308>
2024-12-17 15:11:54 +10:00
Peter Hutterer
561cfd009e doc: unwinding state before stop_emulating is the caller's responsibility
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/308>
2024-12-11 10:09:34 +10:00
Peter Hutterer
cdec01dacd CI: force all auto features to enabled
Since we will automatically disable bits if required dependencies
aren't present let's make sure at least our CI complains.

Closes #70

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/319>
2024-12-10 05:06:49 +00:00
Peter Hutterer
d4b60a7d0d test: rename a variable to shut up ruff with default args
We disable that warning in the CI and pre-commit but it's a simple
fix here that makes sense.

        test/test_oeffis.py:185:9: E741 Ambiguous variable name: `l`

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/319>
2024-12-10 05:06:49 +00:00
Peter Hutterer
504afdea4a test: drop the use of attr
All our uses can be done with dataclasses so we don't need an external
package.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/319>
2024-12-10 05:06:49 +00:00
Peter Hutterer
f2811418dd proto: add two missing comments for consistency
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/321>
2024-12-10 09:39:04 +10:00
Peter Hutterer
beb1de6292 ei: indentation fix
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/321>
2024-12-10 09:37:45 +10:00
Peter Hutterer
2acf42db9c tools/debug-events: add missing linebreaks to the modifier event
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/320>
2024-12-09 12:41:24 +10:00
Peter Hutterer
9ee33b019f test: fix a spuriously failing timeout
When running repeated tests in parallel, this one eventually fails
because the ei.send() doesn't trigger the expected BrokenPipeError.
Use ei.dispatch() instaed and check whether the connection still exists.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
2024-12-06 16:48:48 +10:00
Peter Hutterer
60bc264e75 test: ignore a failure to send a pong
Our automatic pong handler unconditionally sends a Pong back to the EIS
implementation. For some tests and depending on timing we may have
been disconnected already, resulting in a BrokenPipeError that fails
us the test. Ignore that error.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
2024-12-06 16:48:48 +10:00
Peter Hutterer
96f20ae333 test: ignore a ConnectionResetError during our dispatch
If our server disconnects us with data still in the pipe we never picked
up on that data causing heisenbugs depending on whether we read things
(esp. the "disconnected" event) fast enough or not.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
2024-12-06 16:48:48 +10:00
Peter Hutterer
7619bfa9ad test: switch a bool([...]) to any()
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
2024-12-06 16:48:48 +10:00
Peter Hutterer
c169ac63b8 test: keep the announced interface as local variable
This will be more prominent as we add new interface versions and hooking
it up via the right signals is better than analyzing the calllog.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
2024-12-06 16:48:48 +10:00
Peter Hutterer
0cf12a889d eis: remove pending events on eis_device_remove()
This fixes a memleak caused by anything having a device ref when
ei_device_remove() is called. This can happen e.g. if there is a pending
event that hasn't been flushed with a ei_device.frame yet.

Example Sequence:
- client sends an event, event is queued to pending with a ref to the
  device
- next event causes a client disconnect, queuing an emulated seat bind
  of 0
- server calls eis_device_remove()
- client calls eis_device_unref()

One ref is still held in the pending event that was never visible to the
server, preventing the device from being freed.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
2024-12-06 16:48:48 +10:00