Commit graph

534 commits

Author SHA1 Message Date
Peter Hutterer
1592fdd57f Add a version macro for grepable version numbers
Makes it a lot easier than to grep for the lonely 1 or 2 in a codebase
somewhere.
2022-09-07 09:20:27 +10:00
Peter Hutterer
06210ee439 tools: drop help for obsolete --sender option from the eis-demo-server 2022-09-06 08:56:20 +10:00
Peter Hutterer
f7dc4af6e8 log: abstract the auxiliary information into a log message context
This makes the logger API both simpler and more future-proof since we
can easily shove extra information into the context now.
2022-08-11 10:09:34 +10:00
Peter Hutterer
37467881e6 Drop the trailing newline from the log messages
Punt this job to the caller, any structured logging handler doesn't need
them anyway and it makes handling of messages more awkward.

For our default log handlers (fprintf) we can just append them
ourselves.

Fixes #19
2022-08-11 10:09:27 +10:00
Peter Hutterer
876d722356 log: enforce single logical messages only
For all but the simplest loggers, the current approach of "this is a
continuation of the previous message" doesn't work well. The caller
cannot know whether the *current* message is complete until it receives
the next message - but that message may never come.

Drop this approach, if we need to compile multiple messages into one,
we can handle this internally and then pass it all as one message to the
caller.
2022-08-11 10:08:48 +10:00
Peter Hutterer
2858b29f1d log: allocate the log message on demand
This avoids truncation of long log messages.
2022-08-03 10:33:01 +10:00
Peter Hutterer
07f80cc002 proto: split the client's SetProperty from the server event
This makes the code/protocol slightly more readable.
2022-08-02 03:33:32 +00:00
Peter Hutterer
0a382dec3d tools: print property values in the demo client and server 2022-08-01 10:12:06 +00:00
Peter Hutterer
27af399992 tools/demo-client: keep a ref to the ptr/kbd/abs devices
Otherwise calling unref on them on exit makes the demo client go boom.
2022-08-01 10:12:06 +00:00
Peter Hutterer
f6aaedf701 tools/demo-client: stop means stop sending events
The demo client has an inner while loop for the events, followed by
the code to send events to the server. Skip that code if our while loop
indicated we'll stop.
2022-08-01 10:12:06 +00:00
Peter Hutterer
8eee092568 eis: default the client to only the capabilities we know about
Let's not pretend we support capabilities we don't actually know about.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-08-01 11:52:07 +10:00
Peter Hutterer
b3e4f8fc25 test: add a few tests for reis 2022-08-01 11:50:29 +10:00
Peter Hutterer
daddc355b2 eis: add eis_client_has_capability
The EIS implementation needs to know if a client can use a given
capability. No point setting up touch devices if the client isn't
allowed those.
2022-08-01 11:50:29 +10:00
Peter Hutterer
41a106fafc eis: send out the list of existing properties on connect
Any property that was set by the server or a libreis intermediary before
connect needs to be sent to the client.

Fixes #22
2022-08-01 11:31:59 +10:00
Peter Hutterer
b4efd0fa5f test: set up libreis support in eierpecken
The basic set of functions and macros to have access to a libreis
context for our to-be-client.

Since we connect the ei context to a backend during peck_new(), we need
a new function for the case where we do want to have libreis in the
mix.
2022-08-01 11:31:59 +10:00
Peter Hutterer
223d65858d test: rename the ei AUTOCONNECT behavior to HANDLE_CONNECT
All we do here is decide whether the connect event gets handled, clients
are always effectively connected (i.e. the client does send the connect
request) since we set up the backend during init.
2022-08-01 11:26:32 +10:00
Peter Hutterer
7c08308129 util: only do flag_* operations if the bit fits
This silently ignores any bit higher than the target storage (e.g.
flag_set(some_uint32, 33)) but that's still better than silently writing
into random memory.

Add a c file for util-bits.h as well - only contains the tests but at
least that way those are picked up like all other util tests.
2022-07-29 15:43:48 +10:00
Peter Hutterer
d6afe9cef2 Remove a double semicolon 2022-07-29 13:38:28 +10:00
Peter Hutterer
0ee55051f3 proto: document that only one ConfigureName is possible 2022-07-28 14:58:35 +10:00
Peter Hutterer
ba05b9d683 proto: split the Configure messages out a bit
No functional changes though it is a protocol ABI change: group the
Configure messages into their own opcode range.
2022-07-28 11:05:10 +10:00
Peter Hutterer
a70d0af48f proto: document ConfigureCapabilities
Write a bit more of a blurb, with the goal of this eventually being the
protocol documentation.
2022-07-28 11:04:46 +10:00
Peter Hutterer
2142daadc5 eis: capabilities can only be reduced
If a REIS implementation sends multiple ConfigureCapabilities messages,
the allowed capabilities would be whichever ones were sent last rather
than the intersection of all capablities.

Fallout from 7fc9498f1d.
2022-07-28 11:01:08 +10:00
Peter Hutterer
2ec3ced24c proto: specify that Configure messages must be sent before connection
There's a very limited use for configure messages after client
connection. The name is already static after connect anyway, and
the ability to drop capabilities after connect would just complicate the
EIS implementations unnecessary.
2022-07-28 10:35:07 +10:00
Peter Hutterer
61213f3a26 proto: reformat according to the Google Style Guide
2 space indentation, see
https://developers.google.com/protocol-buffers/docs/style
2022-07-28 10:35:07 +10:00
Peter Hutterer
91a604656e reis: drop unnecessary variable rc 2022-07-28 10:35:07 +10:00
Peter Hutterer
dde6af06e2 reis: fix return code handling in allow_capabilities
send_msg() returns zero on success or a negative errno otherwise.
2022-07-28 10:35:01 +10:00
Peter Hutterer
9e7016e1fe Add a comment that reserved properties cannot be set by the API 2022-07-26 13:16:41 +10:00
Olivier Fourdan
1ef00d449c README: Xwayland is a Wayland client
Xwayland is not a compositor, it's a Wayland client.

Also fix a few typos while at it (XWayland -> Xwayland).

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2022-07-18 10:28:22 +02:00
Peter Hutterer
a6ea982bca libei 0.3 2022-06-07 10:35:39 +10:00
Peter Hutterer
b4a7cc9655 README: update with info about sender/receiver modes
And make a note about the protocol eventually maybe becoming an actual
protocol.
2022-06-07 10:34:09 +10:00
Peter Hutterer
b4da6738d3 Retrofit event timestamps to all device events based on the frame
As we now buffer device frames we can apply the timestamp of the frame
event to all currently pending events.
2022-05-17 15:31:20 +10:00
Peter Hutterer
48bf74a5b9 Add a pending event queue for incoming device events
Incoming device events are now added to a device-internal queue. Once
the frame event comes in, that queue is shuffled over to the main event
queue. For libei/the EIS implementation this means that device events
are seen only once the frame event appears from the sender (or it is
emulated by other means).
2022-05-17 15:31:20 +10:00
Peter Hutterer
8e95e8994b ei: expose ei_event_get_context() internally 2022-05-17 15:31:20 +10:00
Peter Hutterer
0d5ce5dd87 util: add the macros to run through a list backwards
This ended up being unused but I wrote the code so we might as well
include it.
2022-05-17 14:36:39 +10:00
Peter Hutterer
d99e42b808 Add timestamps to frame events
Currently only implemented for frame events, the vague plan for the
future is to merely queue the device events internally and "release"
them once a frame event was received, retrofitting the timestamp to the
C event struct (i.e. making ei_event_get_time() available on all device
events).

Meanwhile, the frame event it is.
2022-05-17 07:18:41 +10:00
Peter Hutterer
e913462a23 Print the strerror too if a message fails 2022-05-16 14:15:03 +10:00
Peter Hutterer
8cff3cfd10 Remove an outdated comment
We must support virtual devices on receiver contexts - that's the only
way to handle relative pointer devices that move in pixel(-ish) units.
2022-05-09 17:46:40 +10:00
Peter Hutterer
5b286a4d3a ei: add receiver handling for empty/flushing frame events
Where the sender sends empty frame events, or a device event without a
subsequent frame events ensure that event is filtered or emulated in our
event queue.

Note: because of our sender filters, we cannot actually test
this, at least not easily. Let's hope it works.
2022-05-05 13:46:26 +10:00
Peter Hutterer
f0605b5e53 Add a filter for empty frames on the receiver side 2022-05-05 13:41:36 +10:00
Peter Hutterer
6f230edfa8 Assert on start_emulating if we're left with a pending frame event 2022-05-04 13:42:27 +10:00
Peter Hutterer
5b82cb4fe8 Flush the frame event before a stop_emulating 2022-05-04 13:42:27 +10:00
Peter Hutterer
1fd88a364c Warn if the touch isn't down for a touch motion 2022-05-04 13:27:16 +10:00
Peter Hutterer
1f37500607 Add a bunch of warnings when sending events outside of emulating 2022-05-04 13:26:12 +10:00
Jonas Ådahl
4c874469d5 Only auto-stop emulating if sender 2022-05-02 06:46:18 +00:00
Peter Hutterer
425c7804d4 test: ensure we only get frame events after device events
Because we're doing this per dispatch call (rather than a device state)
we need to ensure that the various tests gobble up all pending frame
events - the assert_no_events helpers do this.

If we only check for specific events, a frame event may still be pending
from one interaction. This causing the assertion to fail on the
subsequent dispatch call.
2022-04-29 11:38:25 +10:00
Peter Hutterer
a4dde7c35f Filter empty frame events
We only need frame events after device events (pointer, touch,
keyboard). In some cases, the library prevents an event from being
written to the wire, e.g. if the coordinates are out of region, but the
client will still call ei_device_frame() for that now-filtered event.

Keep a boolean to remember if we have sent something that requires a
frame event and filter accordingly.

Note that this currently filters the *sender* side only, not the
receiver side. A sender that gets an empty frame event onto the wire
will still get that into the other side.

This also doesn't handle the flushing of frame events before other
events, ideally we should enforce a frame event before e.g. stop
emulating.
2022-04-29 11:38:07 +10:00
Peter Hutterer
35aca1a387 Enforce a frame after ei_touch_destroy()
Destroying a touch causes ei_touch_up if the touch is still down. But
for the event sequence to be correct we also need to add a frame event
here, otherwise the touch up may be "pending" on the remote until the
next actual event happens and a frame is added.

A client that doesn't want this should just call ei_touch_up()
2022-04-29 11:38:07 +10:00
Peter Hutterer
cede41d190 Only send touch up events on destroy if the touch is down
Otherwise we trig a bug error message every time we unref the touch.
2022-04-29 11:38:07 +10:00
Peter Hutterer
ea6a348399 test: add a few missing frame events 2022-04-29 11:38:07 +10:00
Peter Hutterer
e345474515 ei: frame events must be sent on state emulating, not resumed 2022-04-29 11:38:07 +10:00