Commit graph

478 commits

Author SHA1 Message Date
Jonas Ådahl
c9c0fbd55d eis: Remove eis_backend_fd_add_fd()
eis_backend_fd_add_client() should be used instead.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2022-04-27 02:00:07 +00: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
Jonas Ådahl
e115c6549b eis: Add API to add client getting an fd
Creates the socket and adds it; is intended to be used to create client
connections that are passed via a secure channel, e.g. via portals.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2022-04-27 02:00:07 +00:00
Peter Hutterer
a330b31713 tools: add ei-debug-events
Prints out a YAML-compatible list of events for debugging.

This tool also takes a --socketfd argument which names the fd number
that the EIS connection is on. This allows the tool to be started from
some other process that does the EIS connection, e.g. a portal
implementation.
2022-04-22 09:47:04 +10:00
Jonas Ådahl
a68f5a6e83 eis: Fix a couple of coding style issues
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2022-04-21 22:55:13 +00:00
Jonas Ådahl
8571060bf8 eis: Clarify mmap restrictions on keymap
Require to mmap using MAP_PRIVATE, to allow sealing.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2022-04-21 23:39:25 +02:00
Jonas Ådahl
05438a17df libei: Clarify whether a context owns a passed fd
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2022-04-21 23:39:22 +02:00
Peter Hutterer
eea1a24285 tools: fix a few issues in the demo server
A few copy/paste errors and a use-after-free because our demo-client was
never removed from the server list on disconnect.
2022-04-07 14:55:58 +10:00
Peter Hutterer
21985060b9 tools: print the returned negative errno on failure
errno is at some other random value
2022-04-07 13:42:03 +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
42c1a69436 Add ei_is_active()
Typical clients shouldn't need this but the test suite does so let's add
it.
2022-03-28 16:39:10 +10:00
Peter Hutterer
b4afb2014f Correct two comments regarding active vs passive context 2022-03-28 16:38:59 +10:00
Peter Hutterer
3dbd278529 Remove a stray uint32_t from the documentation 2022-03-28 15:36:46 +10:00
Peter Hutterer
c42129c0ff Fix a comment referring to an old implementation 2022-03-28 15:36:46 +10:00
Peter Hutterer
0cca0359af meson.build: fix a deprecation warning 2022-03-28 15:33:13 +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
c012579c51 eis: remove eis_device_set_name(), use eis_device_configure_name()
For consistency with all configure calls
2022-03-07 11:03:30 +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
420c461643 tools: add active/passive mode to the demo server and client
Starting the demo client with --passive initializes a passive context,
and the server will send events to any active context.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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
72cfef9a56 eis: don't allow for region changes once the region was added 2022-03-04 13:59:00 +10:00
Peter Hutterer
9f1db1e10b doc: updates all over the place 2022-03-04 13:47:08 +10:00
Peter Hutterer
d695cf1ab7 doc: fix the documentation for the eis capabilities 2022-03-04 13:46:50 +10:00
Peter Hutterer
30895bd825 doc: document the events a little 2022-03-04 13:46:50 +10:00
David Redondo
46b39c2b38 Some doc fixes relating to keymaps
There are no client created keymaps anymore.
2022-03-03 14:05:20 +01: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
d5bdcfc0da eis: add the functions to fetch a region back from the device
Same as ei_device_get_region() and friends.
2022-03-03 15:03:26 +10: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
a59474b5ca gitlab CI: fail the CI early if the fork is private
Copied from libinput, this provides a better error message than weirdly
failing jobs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-03 00:31:18 +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
6926175e30 gitlab CI: drop the requirement for Signed-off-by
I'm starting to question this, there are plenty of large projects
where this isn't a requirement (GNOME, systemd, ...) and libei doesn't
exactly contain sophisticated technology that needs a DCO.

Plus, it's a constant source of confusion for new contributors.
Let's drop the requirement.
2022-03-03 00:24:41 +00:00
Peter Hutterer
46e65370c6 gitlab CI: add a -Werror job (allowed to fail)
Most of the time we don't pay attention to the details in the actual
jobs, them passing is good enough. So let's have at least one job with
-Werror that fails if our CI has warnings we don't have locally.
Allowed to fail because we don't want to be beholden to compiler changes
(though having this fail for a long period makes the job less useful
again).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-02 16:26:16 +10:00
Peter Hutterer
06ce6c3a92 gitlab CI: move the pages job configuration to config.yml
Makes it less error-prone to forgetful updates like 191913, I hope.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-02 16:26:16 +10:00
Peter Hutterer
12e6eed191 meson.build: don't pass werror through to munit
We don't control compiler warnings in that project and currently we
always get one, so let's not prevent werror from working.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-02 16:26:16 +10:00
Peter Hutterer
d2166bf2bd Documentation updates
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-02 15:55:04 +10:00
Peter Hutterer
fb4b11de43 Fix a typo in the docs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-02 15:55:04 +10:00
Peter Hutterer
97b7a27241 libei 0.2 2022-03-02 10:05:52 +10:00
Peter Hutterer
60523606cf meson.build: add -Wno-unused-variables when buildling with clang
The test suite makes a lot of use of this pattern:
	_unref_(ei_event) *ev = peck_ei_event(....)

Most of the work is done in the peck function, with the caller just
needing cleanup. Unfortunately clang sees this as unused variable and
insists on warning about all of them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 23:28:49 +00:00
Peter Hutterer
ca34a091ac meson.build: add a few compiler flags
And handle them through the compiler.get_supported_arguments() function
in meson.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 23:28:49 +00:00
Peter Hutterer
5ab50db599 util-io: avoid variable length arrays for clang's benefit
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 23:28:49 +00:00
Peter Hutterer
6a3b4a31c6 util-tristate: mark the inline functions as used for clang's benefit
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 23:28:49 +00:00
Peter Hutterer
d6a654adcc util-object: define the cleanup helper functions as used
Cuts down on approximately a million compiler warnings with clang.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 23:28:49 +00:00