Commit graph

79 commits

Author SHA1 Message Date
Peter Hutterer
ebefdf903c protocol: document the protocol better 2023-03-03 11:21:26 +10:00
Peter Hutterer
0a347f433f protocol: make the connection setup the zero object with a proper handover
This changes the initial connection negotiation to have the
ei_connection_setup as the pre-existing object id 0. Once the client has
sent all the data to set up the connection, the EIS implementation
replies with a new object ID that is the ei_connection protocol object,
i.e. the main object.

This allows for version negotiation of our main protocol object.
2023-03-03 11:21:26 +10:00
Peter Hutterer
23433d3aff protocol: move the keymap into the keyboard interface 2023-03-03 11:21:26 +10:00
Peter Hutterer
4d9ca1796d protocol: move pointer/keyboard/touch into separate interfaces
This allows us to have a device support multiple interfaces and evolve
those interfaces individually, e.g. add things to the keyboard interface
without having to bump the touchscreen interface.

Note that due to a name clash with the existing struct ei_touch public
API the protocol interface is named touchscreen.
2023-03-03 11:21:26 +10:00
Peter Hutterer
964bb76c60 protocol: move the frame event into the device interface 2023-03-03 11:21:26 +10:00
Peter Hutterer
3fc1bdf07a protocol: move start/stop emulating into the device 2023-03-03 11:21:26 +10:00
Peter Hutterer
fadc1853c9 protocol: add the ei_device interface
Sitting nested below the ei_seat, the client gets a notification for a
device through the ei_seat.device event.
2023-03-03 11:21:26 +10:00
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
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
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
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
Peter Hutterer
3bcb6fe7f7 proto: drop the varint values, replace with fixed size ones
uint32 in protobuf is encoded as VARINT (roughly similar to UTF-8 but
for numbers). Thats useful when you're sending lots of messages over the
net but in our case having a simple fixed-size protocol message format
is better.
2023-02-09 11:47:45 +10:00
Peter Hutterer
29da572dca proto: separate pre-connection properties into ConfigureProperty
This is primarily for namespacing: where a portal sets some properties
it needs to do so *before* the Connect event. By moving this out to a
different namespace we can separate this easier, avoiding a portal
accidentally sending a property event after it has already passed the fd
to the client.

Fixes #23
2022-09-07 10:07:56 +10:00
Peter Hutterer
2d143904c2 proto: add versioned Configure transactions
The same socket is used for pre-connection configuration by a portal and
for the actual client that then uses the data. The portal and the client
may need different protocol versions *and* there may be different REIS
intermediaries.

So let's allow version negotiation for the configuration through
transactions: a REIS intermediary must start/finish a transaction with a
given version number.

This is only partially implemented in libreis right now: each API call
is wrapped in a transaction. Since we support version 1 only anyway,
there's no need to do anything but send our version down the wire. In
the future where we actually need to negotiate, libreis will need a
reis_dispatch() so we can wait for the server version to arrive, parse
it, etc. before sending ConfigureVersion down the wire. It's likely this
will never be needed.
2022-09-07 09:43:03 +10:00
Peter Hutterer
5535692ee0 proto: allow the client to set the protocol version
Let the client set the version number it wants on Connect. There is new
public API to query the client/server's version as set once the connect
finished (eis_client_get_version() and ei_get_version()) but there is
currently no public API for the client to select the version it actually
wants, other than whatever both support. IOW, it's not possible for the
client to say "I want version 8 but if that's not supported, use version
5".
2022-09-07 09:42:59 +10:00
Peter Hutterer
08a4ce4aac proto: add a version exchange prior to connect
Add a new protocol message "GetVersion" and the matching reply from the
server with "Version" that can be sent at any time. The server always
replies with the highest protocol version it supports, allowing the
client to choose the protocol version it wants.

These two messages also have a fixed string to make the protocol easy to
identify in hexdumps.

To avoid roundtrips on connection, libeis immediately sends the Version
message. Ideally and by the time the client actually starts, that
version is already available and we can continue without requiring a
full roundtrip.

This patch only adds the version exchange with the server, it does not
yet add the bits for the client to actually set the version.
2022-09-07 09:30:39 +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
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
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
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
f35be22d2c Rename ei active/passive to sender/receiver
This is more explicit in what it actually does, making it easier to
immediately understand the code.
2022-04-04 15:42:27 +10:00
Peter Hutterer
fa091d7ac4 Differentiate between physical and virtual devices
With passive libei contexts receiving events sent by the EIS
implementation, the type of device changes significantly. While a
relative input device could still send data in logical pixels,
absolute devices may not have that luxury.

Best example here is an external tablet (think: Wacom Intuos): that
tablet has no built-in mapping to a screen and thus cannot capture input
events in logical pixels.

Address this by adding a device type, either virtual or physical.
In terms of functionality, the device's type decides:
- only virtual devices have regions
- only physical devices have a size

The event API remains as-is but the event data not represents either
logical pixels (virtual devices) or mm (physical device).

An EIS implementation connected to a passive libei context would likely
create:
- a virtual relative device (sending deltas in logical pixels)
- one or more physical absolute devices (sending deltas in mm)
2022-04-04 05:28:36 +00:00
Peter Hutterer
9d85b1289d Change to allow dynamic binding of capabilities
Previously, a client could only bind to a capability immediately after
SEAT_ADDED and with a rather awkward API to confirm the capabilities.

Change this to allow for dynamic binding of capabilities, i.e. a client
calls ei_bind_capability() or ei_unbind_capability() whenever it feels
like, causing the respective devices of this capabilty to be added or
removed.

This allows for clients that are temporarily disinterested in a
capability but may require said capability later.

The default function takes one capability, a helper for enable/disable
multiple capabilities in one go is provided as well. On the protocol,
only the "bind" request exists which always represents the currently
wanted set of capabilities.

Note that the helper functions for multiple capabilities require NULL
(not zero) as sentinel, thanks to gcc.
2022-04-04 05:24:16 +00:00
Peter Hutterer
7b760e5950 eis: the EIS context does not have a is_active setting
This is a leftover from an earlier implementation that didn't get
removed in time. This extends to a macro that was using the context flag
(rather than the client flag) and in turn caused a bunch of false
positives on the tests.
2022-03-28 16:53:11 +10:00
Peter Hutterer
faa9500afe Add concept of active/passive libei contexts
A libei context can be initialized as active or passive context -
an "active" context sends events, a "passive" context receives events.
The EIS context supports both simultaneously, it is up to the
implementation to disconnect libei clients that it does not want to
suppport.

For example, the xdotool use-case creates an active libei context. The
EIS implementation controls and sets up the devices, but libei
sends the events.

In an input-capturing use-case, the EIS implementation controls
and sets up the devices **and** sends the events. libei is merely the
receiver for any event, it cannot send events. Thus this use-case
requires a passive libei context.

Most of this code is copy/paste with minor modifications - libei already
had the code to send events, libeis had the code to receive events, so
the vast majority of this patch is copying the code into the respective
other library, swap "ei" and "eis" and then apply the various minor
modifications needed to hook into the existing library.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-04 14:04:33 +10:00
Peter Hutterer
e3ed2c4ee6 proto: group the client messages vs events
This is just for easier readability and extensibility.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-28 02:23:40 +00:00
Peter Hutterer
e885e5e3da proto: remove two superfluous semicolons
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-22 00:57:36 +00:00
Peter Hutterer
44b986daec proto: correct a few comments dating to an earlier version of this
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-22 00:57:36 +00:00
Peter Hutterer
7fc9498f1d reis: simplify the library a bit
Pass the fd into the original context creation, then write any changes
to the wire immediately. For the capabilities that means we can't build
them up as before anymore, so change the API to have a vararg function
and require the allowed capabilities to be passed in.

There's likely little use for the previous allow-vs-deny policy etc, so
let's not make things more complicated an they have to be.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-26 10:14:03 +10:00
Peter Hutterer
6768b8170b reis: use the same message helper macro we already use for eis/ei
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-26 09:39:59 +10:00
Peter Hutterer
1225bcb0e1 Add a property API for generic key/value exchanges
There is data that libei and the EIS implementation will want to
exchange that is not covered by the immediate API.

To avoid having to add APIs for all of these, let's provide a generic
property API that both server and client can use to exchange this info.

The property API provides read/write/delete permissions but those only
apply to the client, not the server. The idea is that a server can
create (or restrict) properties that the client can read but not modify
and/or delete. A special-case are properties filled in automatically by
libei: ei.application.pid and ei.application.cmdline. These could be
used by e.g. the portal implementation to match permissions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-25 13:35:36 +10:00
Peter Hutterer
1bb5e103ab Split connect into an additional connect_done
This allows us to transmit extra information about the client before the
server has to decide on whether it wants to connect us.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-25 11:25:32 +10:00
Peter Hutterer
a03f547989 proto: add a start/stop emulating message pair
This effectively provides the EIS implementation with a notification
that the client will actually send events in the near future. To be used
by e.g. synergy-like clients when the pointer enters the logical screen
so that the EIS implementation can flash a warning or something.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-24 13:14:20 +10:00
Peter Hutterer
1884785a8a Add a scroll stop/cancel event
This allows a client to trigger kinetic scrolling (or prevent it).
For compositors implementing EIS, the only realistic scroll source is
continuous which allows for scroll stop events. So let's give the client
the opportunity to trigger those on demand.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-24 09:21:05 +10:00
Peter Hutterer
55594cd09c Add a frame event to logically group events together
Already present in e.g. libinput and wayland, this event allows us to
group several events together to denote them as a logical group.
Required for multi-touch but as we've learned with Wayland it's also
required to group other events (scroll events in the case of Wayland).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-24 09:21:05 +10:00
Peter Hutterer
6f70e97cce Implement key modifier mask events similar to Wayland
Since the server controls the keymap, and that keymap is likely merged
with some other device let's add the events so we notify the client of
things like numlock-is-down etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-23 15:03:15 +10:00
Peter Hutterer
730a82d28d proto: rename the Frame message to Packet
We're about to use Frame in the protocol itself, so let's not make those
confusing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-23 15:03:15 +10:00