Commit graph

461 commits

Author SHA1 Message Date
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
Peter Hutterer
6afd5c2f94 Drop "static" from some clang-says-the-re-not-const variables
Looks pretty const to me but compiler authors presumably have a
different interpretation.

../src/libei-log.c:52:34: error: initializer element is not a compile-time constant
        static const char *reset_code = ansi_colorcode[RESET];
                                        ^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 23:28:49 +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
2c4506fdb8 Drain all data from the fd if we are disconnecting anyway
If we get EPROTO or EINVAL on the connection, all we do is disconnect
(ourselves or the client). So let's drain the fd so there's no other
data to be parsed by accident and then continue with actually
disconnecting.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 23:25:43 +00:00
Peter Hutterer
e36e856141 meson.build: use the SPDX identifier for the license
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 14:03:02 +10:00
Peter Hutterer
b3b0866bd4 doc: fix a doxygen complaint
<pid> was interpreted as html

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 13:48:43 +10:00
Peter Hutterer
7f6312c043 doc: fix some invalid \ref commands
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 13:47:57 +10:00
Peter Hutterer
c88435e51b doc: expand the mainpage with an illustration
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 13:46:32 +10:00
Peter Hutterer
6f0172a179 eis: namespace the internal event handlers
We will need eis_device_foo() for the actual event API soon, so let's
move the internal handlers out of the way by namespacing them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-28 02:23:40 +00:00
Peter Hutterer
86488fdc5a eis: streamline the event handlers a bit
Use a helper function to find the device, no need to duplicate these
loops everywhere.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-28 02:23:40 +00:00
Peter Hutterer
bbbf2ff0f2 ei: add a helper function to create an event from a device
Just cuts down on duplication/room for error

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-28 02:23:40 +00:00
Peter Hutterer
e3ed2c4ee6 proto: group the client messages vs events
This is just for easier readability and extensibility.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-28 02:23:40 +00:00
Peter Hutterer
56187e1543 eis-demo-server: add ei client tracking
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-28 02:23:40 +00:00
Peter Hutterer
7a91f27d42 eis: fix an error when the seat is removed twice
Previous sequence reproducible with the eis-demo-server and
ei-demo-client:
- ctrl+c the client
- eis client dispatch fails with an rc < 0 due to the socket being closed
- eis calls eis_client_disconnect() which calls eis_seat_removed()
  - that triggers an event for `SEAT_UNBIND`
  - seat is set to REMOVE
- eis-demo-server gets the `SEAT_UNBIND` event and (correctly) calls
  eis_seat_remove() since it doesn't know the client is disconnected
  yet. That is due to the library unwinding the state transparently.

Fix this by splitting out the calls: eis_drop_seat() is the internally
used one that sets it to a new state of REMOVED_INTERNALLY, and then
eis_seat_remove merely updates the state.

Fixes #10

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-25 15:48:22 +10:00
Peter Hutterer
6f3a62f5d2 Remove some if 0 code
If 0-ed out in the switch to server-side devices, this can go now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-22 00:57:36 +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
1bcf6c2a61 eis: remove a default statement for better compiler warnings
Requires the same handling as 30d154b0d8
now

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-22 00:57:36 +00:00
Peter Hutterer
e885e5e3da proto: remove two superfluous semicolons
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-22 00:57:36 +00:00