Commit graph

105 commits

Author SHA1 Message Date
Peter Hutterer
c5ebd345fd tools: copy the default log handler to the eis demo server
The default log handler logs to stderr, but we want stdout here to have
it intermixed with our real log messages (easier to debug this way).
Would probably be better to have this somewhere shared but for now this
will do.
2023-03-03 11:16:48 +10:00
Peter Hutterer
1925218e15 tools: whitespace fix in the demo server 2023-02-13 13:24:37 +10:00
Peter Hutterer
92f92bc3a5 tools: cleanup our clients in the eis demo server
Where we're interrupted before a disconnect event from the client, we
would leave the demo client hanging. This upsets valgrind.
2023-02-13 13:24:37 +10:00
Peter Hutterer
129eabcd29 tools: add a comment to the demo server
Might save some other poor soul having to debug this ...
2023-02-13 13:24:37 +10:00
Peter Hutterer
ff9830c122 Add a sequence number to START_EMULATING
This makes it easier to correlate a particular input transaction
(whether there are events or not) with out-of-band information like the
planned portal InputCapture::Activated signal's "activation-id".
2023-02-09 11:48:29 +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
affc464caa util-time: fix the us2ms function
Turns out this was converting in the wrong direction and the only call
site we had didn't notice/care.
2023-02-01 12:52:34 +10:00
Peter Hutterer
eeefb3dc00 liboeffis is a wrapper library for the RemoteDesktop communication
libei used to have direct portal support code (see the git history) but:
- that code was a custom proposed portal that never went anywhere
- libei has slowly changed to be more an input event transport layer since
  it is now also used sending events *to* a libei context
- a number of libei users will never need the DBus code, either because they
  don't want it or because they talk Dbus themselves na ddon't need this
  abstraction.

Luckily, it's quite easy to move this into a separate library with a
simple API that does, effectively, the same trick as the old portal backend.
This API is aiming to be as simple as possible because the tools that
require anything more complex should talk to DBus directly.

An example tool that uses the API to retrieve an EIS fd over the
RemoteDesktop portal is included in this patch.

"Öffis" is a German word meaning public transport. It also sounds like the
French Œuf, the word for egg.

Co-authored-by: Olivier Fourdan <ofourdan@redhat.com>
2022-12-08 11:22:50 +10:00
Peter Hutterer
8fc654bfb0 Purge the portal code
The original idea here was that we would have an EmulatedInput portal
that allows the application to connect directly to the EIS
implementation to exchange input events - instead of ping-ponging DBus
events through the xdg-desktop-portal as the RemoteDesktop portal
requires.

This is no longer accurate, there are suggested PRs open to add
RemoteDesktop.ConnectToEIS to achieve the same through the existing
RemoteDesktop interface [1] and to add a new InputCapture portal
to allow for events to be sent to a libei receiver context [2].

The example EmulatedInput portal is thus superfluous and can be removed
from here.

We could switch the ei_setup_backend_portal() code to use RemoteDesktop
or InputCapture, depending on the context type, the utility of this is
questionable. Interaction with portals is complex, one needs to
implement the Session/Request interfaces correctly and in the case of
InputCapture also handle the complex zones/pointer barrier setup.
libportal does some of this (or it will, anyway) so it's more useful for
an application to use libportal and then just pass the received fd to
libei.

If there is a future need for this to be handled as part of libei, we
can (re)implement this, but for now it's best to just purge all of this.

[1] https://github.com/flatpak/xdg-desktop-portal/pull/762
[2] https://github.com/flatpak/xdg-desktop-portal/pull/714
2022-12-08 10:45:47 +10:00
Peter Hutterer
06210ee439 tools: drop help for obsolete --sender option from the eis-demo-server 2022-09-06 08:56:20 +10:00
Peter Hutterer
0a382dec3d tools: print property values in the demo client and server 2022-08-01 10:12:06 +00:00
Peter Hutterer
27af399992 tools/demo-client: keep a ref to the ptr/kbd/abs devices
Otherwise calling unref on them on exit makes the demo client go boom.
2022-08-01 10:12:06 +00:00
Peter Hutterer
f6aaedf701 tools/demo-client: stop means stop sending events
The demo client has an inner while loop for the events, followed by
the code to send events to the server. Skip that code if our while loop
indicated we'll stop.
2022-08-01 10:12:06 +00: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
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
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
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
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
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
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
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
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
802e5965cc tools: add a blurb to each tool to list what it is for
Let's not force users/developers to dig through the commit log to figure
out what each tool does.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-09-01 12:29:44 +10:00
Peter Hutterer
28532aa9c6 tools: no need to abort on errors in the fake portal
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-09-01 12:29:44 +10:00
Peter Hutterer
b863445c28 tools: default to LIBEI_SOCKET in the fake portal too
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-09-01 12:29:44 +10:00
Peter Hutterer
df5237a7ea tools: update the portal for the latest version
The latest version of the portal communication adds session capabilities
and wraps the calls a bit differently.

This now  also includes a helper tool for the impl.portal part so we can
run xdg-desktop-portal against that without the need for a mutter
implementation.
Use:
- run the eis-demo-server
- run the eis-fake-impl-portal
- run the xdg-desktop-portal (it'll use the fake impl portal)
- run an ei client with the portal enabled

Note that the ei-fake-portal is a shortcut, it will open eis directly
without going through the impl.portal.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-09-01 12:29:44 +10:00
Peter Hutterer
4b3b48291b tools: whitespace fixes in the demo client
And fix a missing field initializer warning while we're here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-27 09:14:00 +10:00
Peter Hutterer
1e8c184d8e tools: set the default properties in the fake portal
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-26 12:47:07 +10:00
Peter Hutterer
6197e5a34e tools: print the default properties from the demo server
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-26 12:47:07 +10:00
Peter Hutterer
95f00361b3 tools: fix a whitespace issue/compiler warning in the fake portal
Whitespace issue originally, but let's fix it so that clang no longer
complains about missing initializers.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-26 08:47:53 +10:00
Peter Hutterer
128e8f1bab tools: fix the wrong default busname documentation for the fake portal
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-26 08:46:41 +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
9013702534 tools: fix the demo clients' frame events for kbd/abs
Unsurprisingly segfaults on EIS implementations that don't provide a
pointer.

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
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
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
5adf87cdda tools: hook up absolute pointer motion in the demo client
Prints the regions and sets the pointer to somewhere around 150/150

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
2ec3328447 tools: use the linux event codes now that we're including the header
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:29:56 +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
712e37eb3b tools: fix a typo
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:09:08 +10:00
Peter Hutterer
a522808253 tools: fix keyboard cap in the EIS demo server
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:09:08 +10:00
Peter Hutterer
ecd75fcf40 tools: add an abs device and regions to the demo server
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-09 15:45:06 +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
David Redondo
27e7823029 Implement support for scroll events
The interfaces were declared on both client and server  side but not
implemented.

Signed-off-by: David Redondo <kde@david-redondo.de>
2021-07-16 08:40:07 +02:00