Commit graph

28 commits

Author SHA1 Message Date
Peter Hutterer
1f9539540e Use a helper macro for the protobuf message setup
All of this is always the same steps, let's use a macro so we can limit
our code to the bits we actually need to do.

This requires renaming some of the protocol itself to match up with the
expectations - not the worst thing since it makes the protocol more
consistent.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-12 15:39:26 +10:00
Peter Hutterer
09929534bf proto: split the touch event into its three separate events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-12 15:39:26 +10:00
Peter Hutterer
379f47b06b proto: split the keymap message out from the device added message
Same approach as used for the regions already, a separate (optional)
message.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:29:58 +10:00
Peter Hutterer
3abf13742a Restructure keymap handling to server-side only
This keeps most of the current structure but gets rid of client-side
keymaps (which have been broken since the server-side devices anyway).
The new approach: clients get a keymap (or NULL) from the server, if
they don't like it they will have to do transformation on their side.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:29:55 +10:00
Peter Hutterer
6095a0d99f Add a physical scale factor for the regions
This isn't something that libei itself uses but clients like synergy
need to know about this to be able to map relative pointer motion from
one host into the right physical pixel on another host.

This is required for mutter in the x11-compat mode where a 4k screen is
logically twice the size of a 2k screen, despite having the same
physical size.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-23 15:06:01 +10:00
Peter Hutterer
56b82c2b8f Add DeviceRegions to replace the pointer/touch ranges
This is required for supporting synergy/barrier and similar clients.
Replacing the touch and pointer range we now have server-defined
rectangular regions that specify the active zones for this device.

For example, a dual-monitor EIS server would create two touch devices
with one region each for the respective monitors - libei-generated
touches would thus fall on the right area of the monitor. Or just one
device with one region if the second screen should be inaccessible.

A relative device may have multiple regions since it can reach all
screens in the layout.

This leaks the screen layout to libei but that is necessary for the
functionality to work. A libei client may need to control devices
through absolute coordinates and it needs to know where screen
transitions from one to the next screen happen:

  +-----------++----------------+
  |           ||                |
  |          B||Q               |
  |           |+----------------+
  |           |
  |          A|P
  +-----------+

In the above example, position P is unreachable and a client that
controls input on both screens must know that it cannot transition from
A to P but it can transition from B to Q.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-23 15:06:01 +10:00
Peter Hutterer
12b04fdeb0 Add a DeviceAddedDone message to the protocol
Similar to wayland's done message, this signals the end of the device
configuration.

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-23 14:26:38 +10:00
Peter Hutterer
2bb846696f Change to use server-created devices
This changes the protocol so that it is the EIS implementation that
creates devices within a seat.

A client now "binds" to a seat and the EIS implementation creates
devices matching the requested capabilities. A client can close a device
if it no longer wants those but otherwise everything (including pointer
ranges) is handled by the server.

This is one giant patch because changes at the protocol level cannot
easily be broken out into smaller patches. Some FIXMEs are left which
will be handled in follow-up patches, e.g. the keymap handling is
basically broken right now.

Fixes #7

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 11:02:54 +10:00
David Redondo
27e7823029 Implement support for scroll events
The interfaces were declared on both client and server  side but not
implemented.

Signed-off-by: David Redondo <kde@david-redondo.de>
2021-07-16 08:40:07 +02:00
Peter Hutterer
93b96e42ad Add an EIS-controlled seat to the hierarchy
After CONNECT, the EIS implementation needs to add one or more seats. The
libei client can only create devices within those seats. This mirrors the
wayland hierarchy as well as the X.Org one.

The seat has a set of allowed capabilities, so the client knows ahead of time
when it may not be possible to create a specific device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 10:47:47 +10:00
Peter Hutterer
40d7b3cade Add support for touch events
Client-side the approach is a managed touch object rather than passing the
touchid around. This is intentional, it allows for a stackable API in the
future if we need to add things like pressure or major/minor to it.

On the server side the touches are managed through the event object anyway, so
we don't need the same abstraction there.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-27 23:48:51 +00:00
Peter Hutterer
90d2b1b980 Add support for absolute pointer motion events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-24 11:24:58 +10:00
Peter Hutterer
09ad65d5c6 Implement eis_device_set_name and get_name
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-24 11:21:46 +10:00
Peter Hutterer
17d396aaf1 Add size handling for the keymap
Just sending the fd isn't good enough, to mmap those we need the size argument
too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 18:57:25 +10:00
Peter Hutterer
819b1e86b1 libei: integration of keymap fd parsing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 15:25:27 +10:00
Peter Hutterer
c4601b7196 Implement device suspend/resume with starting state of "suspended"
This was already spelled out in the documentation but just not yet
implemented. New starting state for any device added by EIS is "suspended",
the server needs to explicitly resume it before events are accepted.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
4565fb6851 libei: add the hooks for pointer/touch ranges
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-18 14:42:23 +10:00
Peter Hutterer
39b5ba74a4 Switch the various coordinates to doubles
Original idea of 1/1000 of a pixel was to allow subpixels while sending fixed
width down the wire. Let's not care about that and use doubles instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-13 16:17:51 +10:00
Peter Hutterer
b547fdc529 Improve naming for the DeviceAdded message
DeviceAdded is more self-explanatory than just "Added"

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-13 16:17:51 +10:00
Peter Hutterer
55246512f0 Add capabilities to the Added event
This makes it possible for the server to limit capabilities.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-10 19:32:34 +10:00
Peter Hutterer
6f75463261 Rename "accepted" to "added" for consistency with the public API
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-10 08:49:22 +10:00
Peter Hutterer
fe22b9b5a5 proto: specify that the protocol isn't batch-compatible after all
The protocol itself could work like originally described here but there's a
stumbling block: the decision on whether to accept a device is made by the
caller through EIS_EVENT_DEVICE_ADDED and the following eis_device_connect()
call. We cannot process any events from that device until that call is
complete and that effectively disallows batch submission of requests.

To allow batching we'd have to pause the protocol but that means missing out
on other devices (and their events) and disconnect events. The alternative to
that would be for libeis to peek at incoming requests and sort them by device
ID so we only pause one device's stream but now we're also mangling the device
event order and potentially triggering all sorts of side-effects.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-10 08:04:05 +10:00
Peter Hutterer
4cfa6e6225 Add configuration messages to the protocol
For the Portal case, we'll have the portal open the sockets for us and then
(depending on policy) restrict what the client can do. Then the socket can be
passed to the client with e.g. keyboards disabled and the client is none the
wiser (other than that the server will reject any keyboard caps).

Since the portal doesn't need a EI context, the configuration is a separate
small library.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-07 16:05:57 +10:00
Peter Hutterer
2f855c568c Drop the "hello" message
The main purpose of that was for (plain-text protocol) debugging. With the
current intentions to "preload" a connection with restrictions, having the
server initiate a connection is not useful.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-07 14:46:20 +10:00
Peter Hutterer
a9f07368a5 Implement pointer button and keyboard key events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-03 12:00:31 +10:00
Peter Hutterer
81d4556dcc proto: add a fixed-length frame message
protobuf relies on external framing and exact buffer lengths to parse things
correctly. So let's provide that by sending a fixed-length Frame message
before every real message.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-03 11:59:05 +10:00
Peter Hutterer
cf6dec8e15 proto: add a protocol specification
Just so it's a bit more obvious what sequences we expect

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-03 07:55:25 +10:00
Peter Hutterer
9f851bcccb Replace the custom message parsing with protobuf
Plain-text was useful for the initial implementation where the counterpart was
netcat but now that both parts are in place, protobuf is a much more
convenient system to handle a frequently-changing protocol.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-31 13:05:11 +10:00