Commit graph

48 commits

Author SHA1 Message Date
Peter Hutterer
44de97d649 test: switch to use ei_seat_bind_capabilities()
Better than one-by-one where we bind multiple capabilities. And
ei_seat_bind_capability() is about to be removed so let's switch all
of them.
2023-05-10 12:21:40 +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
8bdfc8cf18 test: fix a test case's behavior
The default behaviour of a peck context is to handle the CONNECT event.
Let's disable that.

No effect on the test, the client cannot receive the connect event until
it's been accepted, but it's better form anyway.
2023-02-02 15:17:09 +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
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
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
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
19ae05b33b test: define peck_unrefp in the header file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-03 05:41:15 +00:00
Peter Hutterer
c15fcdc140 util: add a helper for fetching the cmdline.
Better than duplicating this three times.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-03 00:43:02 +00:00
Peter Hutterer
46681e2855 Add SPDX identifiers to all source files
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-03 00:27:36 +00:00
Peter Hutterer
5f2afdf806 Fix a bunch of compiler warnings
Most are signed vs unsigned, the remaining ones are an unused
variables/functions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 23:28:49 +00:00
Peter Hutterer
95cca59647 test: remove a set of unused variables
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-22 00:57:36 +00: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
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
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
9449d66828 test: split the ei tests up into different files
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 12:01:05 +10:00
Peter Hutterer
cc78331bba eis: insert an unbind event if we had a bound seat
If our client binds to a seat and then disconnects, insert an unbind
event in the EIS queue to unwind correctly.

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 11:20:30 +10:00
Peter Hutterer
358a528478 Add support for seat unbinding
This required a bit of cleanup with the eis device handling.

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 11:20:18 +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
Peter Hutterer
c317de742b libei: immediately remove devices added for a removed seat
Once the SEAT_REMOVED event has been processed, adding new devices is
pointless. But we do promise a DEVICE_REMOVED event for any device added with
ei_device_add(), so let's immediately queue an event and mark the device as
dead.

Since the SEAT_REMOVED event may still be pending in the queue (i.e. not yet
read by the client), we need to prepend the event to the queue. Note that
client that immediately add a device when a device is removed will cause
an infinite loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-29 14:10:47 +10:00
Peter Hutterer
57fc23c67d libei: require ei_device_remove() for a never-added device
This simplifies the handling of devices that were never added a bit, including
handling the refs between seat and device. And for legitimate use-cases
there's no reason why a caller would create a device but never add it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-29 12:23:35 +10:00
Peter Hutterer
03e5a547f5 test: add a few more tests for disconnection behavior
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-29 11:28:29 +10:00
Peter Hutterer
0558866f5b test: add a test to simulate the xdotool/xwayland behavior
xdotool sends the events and disconnects immediately, Xwayland queues up those
events until it has a seat but then also disconnects immediately. Let's
emulate this behavior so we can catch breakages before Xwayland sees them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-27 11:35:11 +10:00
Peter Hutterer
683ff5cca0 Fix double device removal
Removing a seat could cause two device remove events to happen. Fix this by
splitting the removal up into two bits: removed by server and removed by
client. Only once both bits are set, remove the device.

This needs to happen in libei and libeis.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-27 11:35:06 +10:00
Peter Hutterer
ab386f3cdb util: add an _unref_ cleanup + declaration function
To cut down on the boilerplate, an unref-able struct variable can now be
declared as
   _unref_(type) *name = NULL;
which is the equivalent of
   _cleanup_(type_unrefp) struct type *name = NULL;

Let's see how that style ends up reading.

This means we can get rid of the custom _cleanup_foo_ functions everywhere, no
need for all the extra #defines etc. A somewhat special case is systemd which
defines the various unrefp functions for us in the headers, so we can use them
directly.

OBJECT_IMPLEMENT_UNREF now also creates the unrefp function for this object -
this of course conflicts where DECLARE_UNREF_CLEANUP_FUNC is in scope. Not a
problem so far, let's see how we go.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 11:17:16 +10: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
7318512a89 libeis: switch the keymap to be a separate object
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-01 15:28:46 +10:00
Peter Hutterer
76d59c11c9 libei: switch the keymap to be a separate object
This fits better with the rest of the API and also fits much nicer into the
most common use-case of "device doesn't have a keymap".

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-01 15:28:46 +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
eb40872770 Fix client-side removal of devices
Because events may be in-transit when a client removes the device, we need to
make this a full roundtrip to the server. Otherwise the client may assume a
device is removed, releases all references and then gets the original device
added event for that device. Better to have this as a round-trip instead.

This requires the server to call eis_device_disconnect() on the removed
notifications but we do so during eis_event_unref() anyway in case the server
forgets.

And it changes some of the API behaviors, so adjust the tests for that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-24 10:41:55 +10:00
Peter Hutterer
a89309558a eis: pointer motion is in doubles, not ints
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-23 15:49:44 +10:00
Peter Hutterer
b21bb04c4c test: use the event fetching helpers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-23 15:49:44 +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
8bddc3008f test: expand the ei tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
8a8c72b24e test: rename a helper function
This function dispatches until a stable state is reached - that could be no
event waiting or some event waiting to be processed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
1fdbba2ec9 test: rename two tests to reflect current nomenclature
"reject" isn't a thing, "disconnect" is

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
1fe93ae8be Factor out munit test handling into a set of helpers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
d65c678239 test: add a helper to wait until a stable state
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-18 14:42:23 +10:00
Peter Hutterer
c39dc360d4 test: terminate the test list with NULL
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-18 14:42:23 +10:00
Peter Hutterer
dd426757fb test: fix the suite name for the EI integration tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-12 14:36:10 +10:00
Peter Hutterer
efa01ffc38 test: move the with_server/with_client helper macros to eierpecken.h
We want to re-use those.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-12 14:35:41 +10:00
Peter Hutterer
7d75b3eb8c test: use drop caps, not reject caps as terminology
And add a test that tests for dropped caps

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-11 13:01:36 +10:00
Peter Hutterer
7ae661a029 test: add a test for a device dropped to zero caps and refused
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-11 13:01:36 +10:00
Peter Hutterer
ce51392241 test: fix the device add test
Check that we're actually adding the device and getting the message back

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-11 10:51:30 +10:00
Peter Hutterer
e860d24763 Add a test suite 2020-08-06 16:20:35 +10:00