Commit graph

135 commits

Author SHA1 Message Date
Peter Hutterer
bc78c24290 Fix some logging linebreak issues
One excessive linebreak, another one was missing.
2022-09-07 10:03:11 +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
f7dc4af6e8 log: abstract the auxiliary information into a log message context
This makes the logger API both simpler and more future-proof since we
can easily shove extra information into the context now.
2022-08-11 10:09:34 +10:00
Peter Hutterer
876d722356 log: enforce single logical messages only
For all but the simplest loggers, the current approach of "this is a
continuation of the previous message" doesn't work well. The caller
cannot know whether the *current* message is complete until it receives
the next message - but that message may never come.

Drop this approach, if we need to compile multiple messages into one,
we can handle this internally and then pass it all as one message to the
caller.
2022-08-11 10:08:48 +10:00
Peter Hutterer
b3e4f8fc25 test: add a few tests for reis 2022-08-01 11:50:29 +10:00
Peter Hutterer
daddc355b2 eis: add eis_client_has_capability
The EIS implementation needs to know if a client can use a given
capability. No point setting up touch devices if the client isn't
allowed those.
2022-08-01 11:50:29 +10:00
Peter Hutterer
41a106fafc eis: send out the list of existing properties on connect
Any property that was set by the server or a libreis intermediary before
connect needs to be sent to the client.

Fixes #22
2022-08-01 11:31:59 +10:00
Peter Hutterer
b4efd0fa5f test: set up libreis support in eierpecken
The basic set of functions and macros to have access to a libreis
context for our to-be-client.

Since we connect the ei context to a backend during peck_new(), we need
a new function for the case where we do want to have libreis in the
mix.
2022-08-01 11:31:59 +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
b4da6738d3 Retrofit event timestamps to all device events based on the frame
As we now buffer device frames we can apply the timestamp of the frame
event to all currently pending events.
2022-05-17 15:31:20 +10:00
Peter Hutterer
48bf74a5b9 Add a pending event queue for incoming device events
Incoming device events are now added to a device-internal queue. Once
the frame event comes in, that queue is shuffled over to the main event
queue. For libei/the EIS implementation this means that device events
are seen only once the frame event appears from the sender (or it is
emulated by other means).
2022-05-17 15:31:20 +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
5b82cb4fe8 Flush the frame event before a stop_emulating 2022-05-04 13:42:27 +10:00
Peter Hutterer
425c7804d4 test: ensure we only get frame events after device events
Because we're doing this per dispatch call (rather than a device state)
we need to ensure that the various tests gobble up all pending frame
events - the assert_no_events helpers do this.

If we only check for specific events, a frame event may still be pending
from one interaction. This causing the assertion to fail on the
subsequent dispatch call.
2022-04-29 11:38:25 +10:00
Peter Hutterer
a4dde7c35f Filter empty frame events
We only need frame events after device events (pointer, touch,
keyboard). In some cases, the library prevents an event from being
written to the wire, e.g. if the coordinates are out of region, but the
client will still call ei_device_frame() for that now-filtered event.

Keep a boolean to remember if we have sent something that requires a
frame event and filter accordingly.

Note that this currently filters the *sender* side only, not the
receiver side. A sender that gets an empty frame event onto the wire
will still get that into the other side.

This also doesn't handle the flushing of frame events before other
events, ideally we should enforce a frame event before e.g. stop
emulating.
2022-04-29 11:38:07 +10:00
Peter Hutterer
35aca1a387 Enforce a frame after ei_touch_destroy()
Destroying a touch causes ei_touch_up if the touch is still down. But
for the event sequence to be correct we also need to add a frame event
here, otherwise the touch up may be "pending" on the remote until the
next actual event happens and a frame is added.

A client that doesn't want this should just call ei_touch_up()
2022-04-29 11:38:07 +10:00
Peter Hutterer
ea6a348399 test: add a few missing frame events 2022-04-29 11:38:07 +10:00
Peter Hutterer
e25586a96c test: handle frame events in passive ei contexts by default
This is a copy of the EIS handling of frame events where we largely skip
over them to make the tests more sensible.
2022-04-29 11:37:35 +10:00
Peter Hutterer
9831b4c98b test: use the helper functions to enable the default behaviors
Some of the behaviors we enable trigger others (none that we use here
though), so let's use the helper function to get the same behavior sets
as if we set those in the tests.
2022-04-29 11:16:41 +10:00
Peter Hutterer
ab55d6646b test: make the dispatch looping easier to understand in the debug logs 2022-04-29 11:16:41 +10:00
Jonas Ådahl
1ec6d3dbea eirpecken: Use the new eis_backend_fd_add_client()
This also acts as the test for eis_backend_fd_add_client().

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2022-04-27 02:00:07 +00: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
a5e6af5bff eis: after the client binds the seat, drop the capabilities
This way eis_seat_has_capability() returns the effective capabilities
the server can actually use - no point creating touch devices when the
client has not confirmed that.

In theory we should have a eis_seat_get_effective_capabilities() to
differ between configured and effective capabilities, but I'm having a
hard time thinking of a use-case where the implementation forgets
which caps it enabled.

The side-effect of this patch is that adding a device without
capabilities requested by the client now produces warning.
2022-03-07 11:21:36 +10:00
Peter Hutterer
541dcb415d ei: require the client to confirm capabilities rather than drop them
Our API requires a client to know which capability to pass into the
drop_capabilities function. This doesn't work for capabilities newer
than the client's version so they do not get disabled. The client will
thus receive devices it didn't ask for and doesn't know how to handle.

Let's invert the requirement and require the caller to confirm the
capabilities it wants - all others are dropped.

This is an API break but also requires updates of all clients, the
previous simple case of just calling ei_seat_bind() will now result in
zero capabilities.
2022-03-07 11:02:35 +10:00
Peter Hutterer
8474d03e03 test: add test cases for eis -> ei events
Copy/paste from the normal test-cases, with the appropriate switching of
server vs client and s/eis/ei/
2022-03-04 14:04:33 +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
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
b6f477fb96 util-object: split macro to generate unref into one two
One macro that also defines the cleanup function, one macro that only
defines the unref. This is required for any place where we want to
use cleanup from multiple source files - like the test suite.
2022-03-03 05:41:15 +00:00
Peter Hutterer
cc28d90a82 test: aded a test for key events 2022-03-03 05:41:15 +00:00
Peter Hutterer
81d6fb335d test: add a helper function to mark test progress
Makes debugging easier: just insert a few peck_mark() calls and see
them correctly mixed into the output.
2022-03-03 05:41:15 +00:00
Peter Hutterer
e9e67449d5 test: localize a coordinate set a bit better 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
9e83e2fb3e test: add color printing to the test log output
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-24 13:14:20 +10:00
Peter Hutterer
1cfa62859f test: fix segfault if we're expecting an event on an empty queue
Checking the event type on a NULL event doesn't work too well.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-24 10:31:12 +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
781f4dc1f8 test: add a scroll test
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
8a355bbc2a Add missing scroll/scroll discrete to the test debugging
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-23 15:02:26 +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
5ae3b78689 test: drop an obsolete test
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-23 13:02:26 +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