Commit graph

630 commits

Author SHA1 Message Date
Peter Hutterer
01a2ff2d72 brei: pass the proto object through to send_message
Makes for easier debugging since we can print names instead of just
ids/opcodes.
2023-03-03 11:21:26 +10:00
Peter Hutterer
2a8661f7ad protocol: move the seat bind to the seat object
Needs documentation but we can do this when we're done with everything.
2023-03-03 11:21:26 +10:00
Peter Hutterer
b9037ed4ff protocol: check any incoming/outgoing messages for versions
Don't let a interface version 2 send version 3 request or receive those
events.
2023-03-03 11:21:26 +10:00
Peter Hutterer
c98a9fc7d7 eis: update libeis-client to use the declare macros 2023-03-03 11:21:24 +10:00
Peter Hutterer
bcece3d3c1 eis: make sure our connection setup has the right version too 2023-03-03 11:20:42 +10:00
Peter Hutterer
aaf72f9263 protocol: add a seat interface
Incomplete, only supports the initial seat setup but binding to a seat
is still outside this interface.
2023-03-03 11:20:42 +10:00
Peter Hutterer
d95236aa3e Add the ei_callback interface versions
We can now bump ei_callback to a higher version if the client supports
it.
2023-03-03 11:20:42 +10:00
Peter Hutterer
a778a22e26 protocol: add an interface version announcement to the connection setup
The idea here is that the client announces the interfaces it can support
and their version (including the core ei_connection). The server can
then send the various bits based on those versions, where applicable.
2023-03-03 11:20:42 +10:00
Peter Hutterer
09826b8bd3 eis: add a reason to the disconnect message
Allows for slightly easier debugging in the case where we get
disconnected after some protocol error.
2023-03-03 11:20:42 +10:00
Peter Hutterer
db786c7822 protocol: add a ei_connection_setup interface
This replaces the connect/connect_done and version/get_version requests.
Immediately after connecting, the server sends an ei_protocol_setup
event to the client with the ID of the object and the server's highest
supported version number (of this object).

This is a one-shot object that the client can use to configure its name
and whether it is a sender or receiver context. Once .done is sent, the
object is discarded.

The server version is sent along to the client to allow for requests to
be added to this object in the future.

As a fixme left: the client now assumes to be connected as soon as the
.done request is sent and the following sync event is received. The
EIS implementation will not have actually eis_client_connect()ed the
client yet, but it's good enough for now.

Arguably, the CONNECTED event is superfluous anyway since *any* event
other than DISCONNECTED indicates connected status. CONNECTED is a
leftover from when the client created devices and needed to know if it's
worth doing so.
2023-03-03 11:20:42 +10:00
Peter Hutterer
9cbce95326 protocol: add a sync request and the ei_callback interface
Directly copied from wayland. Note that while the wayland protocol
specifies the data is the last event serial in our case here it's just
0 since we don't have any event serials (yet).

The sync request is currently triggered after connection, merely to
ensure it works, it's not actually needed.
2023-03-03 11:20:42 +10:00
Peter Hutterer
d0e6c251b6 protocol: rename the ei core interface to ei_connection
In the protocol this is a simple rename but in the implementation we can
now separate the protocol object out from the ei/ei-client context
itself by having the ei_connection objects.
2023-03-03 11:20:42 +10:00
Peter Hutterer
b02b4f0901 Drop protobuf in favour of a custom protocol
This protocol is wayland-like though it uses a slightly different
message format. The XML file uses the same structure, except for the
"fixed" type which is "float" here.

The scanner uses a jinja template to generate source and header files
for ei and eis which are now used instead of the protobuf-generated
objects. Note that the scanner is a minimal working version, some
features like enum value checks are not yet implemented.

Unlike wayland we do not need to generate the libwayland-like library,
we only need the wire protocol parser - some shortcuts can thus be taken.

To keep the changes simple, the protocol currently is a flat protocol
with only one interface and all messages copied over from the previous
ei.proto file. In future commits, this will be moved to the respective
interfaces instead.
2023-03-03 11:20:42 +10:00
Peter Hutterer
49c329e0de util-io: add a few helper functions to iobuf
Currently unused, but will be in the future
2023-03-03 11:20:42 +10:00
Peter Hutterer
f5e3177f27 ei-device: use the setter declaration macros 2023-03-03 11:20:42 +10:00
Peter Hutterer
ba55bef917 Add ei/eis getters for the device id 2023-03-03 11:20:42 +10:00
Peter Hutterer
e3c34830db ei: rename ei_set_connection to ei_set_socket
Current plans are to use the "connection" term for the ei_connection
interface in the (future) protocol, so let's rename this to avoid
clashes.
2023-03-03 11:20:42 +10:00
Peter Hutterer
1ddf8058e6 util: mmap with MAP_PRIVATE instead of MAP_SHARED
Our only use-case where we use this utility is for keymaps. Those have
to be MAP_PRIVATE in wayland's wl_seat version 8 so let's do the same to make
make sure we're compatible.
2023-03-03 11:16:48 +10:00
Peter Hutterer
d95c1d30f8 util: add some mask helpers 2023-03-03 11:16:48 +10:00
Peter Hutterer
e74e0d1c18 eis: use eis_client_get_context instead of parent 2023-03-03 11:16:48 +10:00
Peter Hutterer
7509ee257f libeis: make eis_client_get_context() part of the public API
So we don't need to carry two pointers around in the caller.
2023-03-03 11:16:48 +10:00
Peter Hutterer
c5ebd345fd tools: copy the default log handler to the eis demo server
The default log handler logs to stderr, but we want stdout here to have
it intermixed with our real log messages (easier to debug this way).
Would probably be better to have this somewhere shared but for now this
will do.
2023-03-03 11:16:48 +10:00
Peter Hutterer
f300a4919a util: add msleep() 2023-03-03 11:16:48 +10:00
Peter Hutterer
1748ddaf3d eis: don't EINVAL if a coordinate is outside the region
From the documentation:
"The x/y coordinate must be within the device's regions or the event is
silently discarded."

libei discards it but if it somehow makes it through anyway, let's
discard it again.
2023-02-23 16:01:47 +10:00
Peter Hutterer
e93ad6925c test: set the minimum bits for our test devices
size is required for phys devices and in the future libei will reject
devices with no useful capabilities.
2023-02-20 15:43:22 +10:00
Peter Hutterer
866a754223 ei: implement ei_device_get_width/height 2023-02-20 15:42:56 +10:00
Peter Hutterer
17dfb4580d util: rename xvasprintf to xvaprintf
This doesn't printf into a buffer, so let's rename it
2023-02-16 15:29:18 +10:00
Peter Hutterer
6096a20964 CI: fix typo in the package list
Fixes 1153368946
2023-02-15 16:14:59 +10:00
Peter Hutterer
83f3789954 CI: add a python linter job with Ruff
Same-ish as Flake8 but faster, let's see how that goes.
2023-02-15 09:19:03 +10:00
Peter Hutterer
90f450787a CI: use the ci-fairy image and a venv for the black job
The venv is needed now because black now requires a newer 'packaging'
and fails to installed with:
   ERROR: Cannot uninstall 'packaging'. It is a distutils installed
   project and thus we cannot accurately determine which files belong to
   it which would lead to only a partial uninstall.

So let's use a venv and while we're doing this switch to use the
ci-fairy image so we don't need to worry about docker limits.
2023-02-15 09:17:45 +10:00
Peter Hutterer
fe337d9866 CI: the check-commit and check-merge-request should use the ci-fairy image 2023-02-15 09:09:20 +10:00
Peter Hutterer
1153368946 CI: move the package list to the config.yml file
Using templates for our CI is a bit of overkill but while we have it,
let's make use of it.
2023-02-15 08:23:56 +10:00
Peter Hutterer
5db1085e09 test: drop a bunch of unused imports 2023-02-15 08:20:01 +10:00
Peter Hutterer
0541668443 eis: don't send stop_emulating for a sender device
The check is currently missing from a number of libeis APIs but in most
cases we can blame the EIS implementation and say "don't do this".
Device removal is an exception since that is still required.
2023-02-13 16:18:08 +10:00
Peter Hutterer
b6a901e690 eis: divide the headers up across multiple files
libeis-private.h was getting unwieldly, so let's split this up so
(most) anything eis_foo goes into libeis-foo.h.
2023-02-13 14:01:08 +10:00
Peter Hutterer
8973101313 ei: divide the headers up across multiple files
libei-private.h was getting unwieldly, so let's split this up so
(most) anything ei_foo goes into libei-foo.h.
2023-02-13 14:01:08 +10:00
Peter Hutterer
d1282b3681 Add some extra getters for the context and the eis_client
These are all noops but this way we can ensure that get_context() and
get_client works on all objects - useful for (upcoming) generated code.
2023-02-13 14:00:19 +10:00
Peter Hutterer
56c992f4c6 Remove the public API to query the client version number
With the planned switch to a protocol supporting multiple interfaces
(a la wayland), a single version number is no longer useful. Remove this
API, we can add something more specific later if we need to.
2023-02-13 13:55:44 +10:00
Peter Hutterer
674a7c6915 meson.build: alphabetical sort of the source files
And drop the header files, meson does not require those for dependency
tracking.
2023-02-13 13:46:00 +10:00
Peter Hutterer
aea4138da5 util: undo accidental rename from source->is_active to is_sender
Runaway sed in f35be22d "Rename ei active/passive to sender/receive"
2023-02-13 13:28:31 +10:00
Peter Hutterer
e5b0dfc1a9 util: add macros to declare getters and setters
Reduces the amount of boilerplate that needs to get written.
2023-02-13 13:27:57 +10:00
Peter Hutterer
34ebddf528 util: add a object getter helper for fields as refs
Same as the existing macro, but returns &field instead of field.
2023-02-13 13:27:39 +10:00
Peter Hutterer
1925218e15 tools: whitespace fix in the demo server 2023-02-13 13:24:37 +10:00
Peter Hutterer
92f92bc3a5 tools: cleanup our clients in the eis demo server
Where we're interrupted before a disconnect event from the client, we
would leave the demo client hanging. This upsets valgrind.
2023-02-13 13:24:37 +10:00
Peter Hutterer
129eabcd29 tools: add a comment to the demo server
Might save some other poor soul having to debug this ...
2023-02-13 13:24:37 +10:00
Peter Hutterer
c9b6898afd test: fix pytest loading liboeffis.so
Apparently this test doesn't run in the CI...
2023-02-09 13:04:59 +10:00
Peter Hutterer
ff9830c122 Add a sequence number to START_EMULATING
This makes it easier to correlate a particular input transaction
(whether there are events or not) with out-of-band information like the
planned portal InputCapture::Activated signal's "activation-id".
2023-02-09 11:48:29 +10:00
Peter Hutterer
a5cc87c837 Purge the properties from the protocol
The primary use-case for these properties in libei itself was to send
some fixed information (pid, cmdline and conection type). In the portal
case, these can be obtained out-of-band via the portal. In the
non-portal case these can be obtained from the socket itself (fetch pid,
look up /proc/pid/cmdline) which is just as reliable as trusting
whatever libei sends.

The only other use-case for the properties was the activation id in the
InputCapture::Activated portal signal. This can be achieved with a
serial in the START_EMULATING event.
2023-02-09 11:48:29 +10:00
Peter Hutterer
479bda259a Purge libreis from the repo
libreis was intended for an intermediary to set some information that
the libei client cannot be entrusted with. In particular this was the
application name, the allowed capabilities, and some properties that -
once set - the client could no longer change (appid as probably the only
really useful one). The price for this was a rather complicated version
negotiation dance before the initial CONNECT request.

Now that we have a clear view of what's going to happen -
RemoteDesktop.ConnectToEIS and the InputCapture portal - there is no
longer any need for libreis. The extra information that libreis would've
sent is communicated out-of-band in both portals and are known to the
compositor at the time the connection is being established.

So we can simply drop this, it's no longer required and dropping it
makes the protocol significantly simpler anyway.
2023-02-09 11:48:28 +10:00
Peter Hutterer
8d7d6ca8b7 proto: drop the Packet message, replace with 4 byte prefix
We need some sort of length field to be able to know how long the next
message is. But for simplicity, we might as well just write that
explicitly on the wire instead of wrapping our messages into yet another
message. This makes the wire format slightly simpler since the first 4
bytes are now always the length, without the previous 0x0d prefix
caused by the protobuf encoding.

0x0d == (field number << 3) | wire_type == 1 << 3 | 5
(see https://protobuf.dev/programming-guides/encoding/#structure)
2023-02-09 11:47:45 +10:00