Commit graph

279 commits

Author SHA1 Message Date
Peter Hutterer
5c017654e8 ei: always queue a disconnect event locally
In the case of a refused portal connection we get disconnected before we
had a chance to send the CONNECT message. This still needs to queue a
disconnect event and thus bubble back up to the caller.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-26 16:43:06 +10:00
Peter Hutterer
ed208f8374 ei: add an ei.connection.type property to be filled in automatically
Planned values: 'socket' and 'portal', the latter to be set by the
portal.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-26 12:47:07 +10:00
Peter Hutterer
1ae193160e eis: differ between eis vs ei property updates
If we have libreis setting properties on the connection, this looks to
the server like they're coming from the ei connection. But libreis is a
different context than the libei context later, so when libei
initializes, it may set the same properties again. Since the libei
context doesn't know about the properties, it can't filter internally
and will send the properties to the server.

So we need to do all the permissions checks in the server to make sure
we don't overwrite values that we're not allowed to overwrite.

There are no real restrictions on changing properties from within the
eis implementation (other than not being able to set the reserved
namespaces).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-26 12:44:53 +10:00
Peter Hutterer
b77b9dc059 reis: add property support
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-26 12:29:19 +10: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
4376e8da88 reis: duplicate the device capabilities
Let's keep the three libraries properly separated.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-26 09:53:36 +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
77c898c3b8 eis: fix some documentation copy/paste-o's
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-25 11:25:32 +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
Peter Hutterer
ae6dbbe61c test: move the unhandled event type assertion out of the switch
All the switch cases return early, moving it here means we can drop the
default case and have the compiler warn us about missing cases.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-23 15:02:19 +10:00
Peter Hutterer
b08ec3cea4 ei: split event handling into its own source file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-23 12:26:07 +10:00
Peter Hutterer
f8c2078bd3 ei: use a getter for ei_event_get_seat
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-23 12:26:07 +10:00
Peter Hutterer
e247ffe824 ei: remove non-existing ei_client reference
Copy/paste-o from the EIS bits

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-23 12:26:07 +10:00
Peter Hutterer
a1ee9bdf2f ei: remove an outdated comment
Leftover of client-decided keymaps

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-23 12:25:51 +10:00
Peter Hutterer
fa7b624f93 Rename suspend to pause to indicate it's a "lighter" form of suspending
There's nothing in the protocol to modify the client device state from
the server, so a pause/resume cycle must leave the client with the
same(-ish) state. Pause is really just that, a short "no event now
please". Anything that would require e.g. modifying the device state by
releasing keys or buttons should result in the device being removed and
re-added.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-23 08:34:44 +10:00
Peter Hutterer
91d8b5f6ca Fix a typo
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-23 08:34:44 +10:00
Peter Hutterer
ceaabd0fd5 ei: add missing ei_seat_has_capability implementation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-20 13:32:13 +10:00
Peter Hutterer
014c0ce081 eis: use a lockfile to determine whether we can remove the old socket
Same approach as libwayland-server

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-18 09:10:43 +10:00
Peter Hutterer
225e001c55 eis: close the socket fd on error
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-18 08:54:02 +10:00
Peter Hutterer
eaefaecdd0 eis: fix the seat assignment
We're using the upper bits for seats, just adding 1 clashes with the
device ids.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-17 16:08:26 +10:00
Peter Hutterer
1134630655 ei: ignore button codes below BTN_MOUSE
Filters out the likely bug of a caller hoping that buttons 1/2/3 will
work (as opposed to BTN_LEFT, etc.)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-17 16:05:22 +10:00
Peter Hutterer
0991660820 Add user data to keymaps
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-12 15:39:26 +10:00
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
6749bf3121 eis: split the internal touch API into three functions for down/up/motion
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-12 15:39:26 +10:00
Peter Hutterer
8022f17f4c eis: switch eis to use interface structs
Just like with the libei code, this removes a few layers of indirection

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-12 15:39:26 +10:00
Peter Hutterer
5747cbf8b8 eis: fix the object creation API again
It's now consistently parent_new_child().

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 16:34:10 +10:00
Peter Hutterer
86bac02026 ei: remove another layer of indirection before we hit the protocol
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 11:59:57 +10:00
Peter Hutterer
e3fd50bae7 ei: abstract the requests into an interface struct too
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 11:06:07 +10:00
Peter Hutterer
1a38bad756 proto: swap the ei message parsing for an interface struct
This gets rid of one layer of indirection with the struct message in
between - we can now call from the proto parser into the handling code
directly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 10:49:36 +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
3aa75890e9 eis: change the regions API to use eis_region_add()
This is slightly inconsistent with the configure API but more consistent
with the device API (which also has a new() + add()). It reduces
potential bugs though because the region cannot be added to two devices
anymore, and this way we also get a context in the region from the start
(which means we can log).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:09:08 +10:00
Peter Hutterer
0f9030c588 doc: fix the docs for the connect event
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:09:08 +10:00
Peter Hutterer
4ef359dc9b Fix a debug message
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:09:08 +10:00
Peter Hutterer
59c4aef9d7 ei: drop pointer/touch width and height
Obsolete now that we have regions

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:09:08 +10:00
Peter Hutterer
cb4dcaa078 ei: two more bug log messages
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-09 18:48:11 +10:00
Peter Hutterer
15316dd2ab Add two convenience methods for region point conversion
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-26 15:45:08 +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
0578a8cbb6 doc: fix some doxygen markup errors
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-23 14:25:56 +10:00
Peter Hutterer
926644e669 util: remove the need for a tmp argument in list_for_each_safe
With a bit of trickery, we can declare the tmp variable inside the for
loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:13:03 +10:00
Peter Hutterer
c0f9e40282 Pass the file/line/func information through to the ei/eis loggers
This is useful for debugging, let's pass it through and let the log
handler decide whether to use it or not.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:09:39 +10:00