Commit graph

85 commits

Author SHA1 Message Date
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
c9b374c383 test: bring back the keymap tests
We can drop the test of the server overriding the client's keymap,
that's no longer a thing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:30:05 +10:00
Peter Hutterer
55b79c44a5 test: check for 2 empty dispatch run before considering a stable state
With keymap messages, we may get and process data on the wire
but it doesn't necessarily result in a visible event. We need to enter
dispatch again to process the data in the next packet.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-11 09:29:50 +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
6095a0d99f Add a physical scale factor for the regions
This isn't something that libei itself uses but clients like synergy
need to know about this to be able to map relative pointer motion from
one host into the right physical pixel on another host.

This is required for mutter in the x11-compat mode where a 4k screen is
logically twice the size of a 2k screen, despite having the same
physical size.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-23 15:06:01 +10:00
Peter Hutterer
56b82c2b8f Add DeviceRegions to replace the pointer/touch ranges
This is required for supporting synergy/barrier and similar clients.
Replacing the touch and pointer range we now have server-defined
rectangular regions that specify the active zones for this device.

For example, a dual-monitor EIS server would create two touch devices
with one region each for the respective monitors - libei-generated
touches would thus fall on the right area of the monitor. Or just one
device with one region if the second screen should be inaccessible.

A relative device may have multiple regions since it can reach all
screens in the layout.

This leaks the screen layout to libei but that is necessary for the
functionality to work. A libei client may need to control devices
through absolute coordinates and it needs to know where screen
transitions from one to the next screen happen:

  +-----------++----------------+
  |           ||                |
  |          B||Q               |
  |           |+----------------+
  |           |
  |          A|P
  +-----------+

In the above example, position P is unreachable and a client that
controls input on both screens must know that it cannot transition from
A to P but it can transition from B to Q.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-23 15:06:01 +10:00
Peter Hutterer
c0f9e40282 Pass the file/line/func information through to the ei/eis loggers
This is useful for debugging, let's pass it through and let the log
handler decide whether to use it or not.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:09:39 +10:00
Peter Hutterer
7f4c8b8247 util: pass the file/line/func information through to the logger
This is useful for debugging, let's pass it through and let the log
handler decide whether to use it or not.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:09:39 +10:00
Peter Hutterer
b527128c27 test: don't print the message type for debug
Make Warning, Info and Error stick out more this way

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:09:39 +10:00
Peter Hutterer
ea8b9d3cb8 test: better debugging of event passing
Log when we're passing an event up to the test case, makes tracing
things easier.

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 11:30:13 +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
96109fb415 test: when dropping the ei context, also drop our seat ref
Otherwise we don't actually clean up everything, making the whole thing
pointless.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-28 15:41:29 +10:00
Peter Hutterer
11857968c6 test: handle dispatch helpers for NULL contexts
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-27 13:30:43 +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
1db2af00c5 test: some better debugging of events
Add a debug marker to show any changes done during the final event processing,
and print the event name for wrong event types.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-26 14:35:57 +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
2076057ba2 util: add a macro to create unref cleanup functions
Slightly less boilerplate than before.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 10:47:47 +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
631fb3c0af Add C++ header guards
And a basic build test for C++ to make sure including the headers doesn't
completely fail.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-29 17:30:49 +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
c0aad25ae9 test: add a new peck EI behavior flag
The simple case - auto-handle anything until the first non-administrative
device event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-23 15:49:44 +10:00
Peter Hutterer
f6f8aa1fd1 test: improve debug logging for the integration tests
Visually easier to get a grasp on what's happening now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-23 15:49:44 +10:00
Peter Hutterer
003075c013 test: better debugging for missing events
Log the event type that is expected

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
4de3380a88 test: make the peck_dispatch_until_stable() a macro
This way we can insert the line number for easier debugging

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-23 09:41:23 +10:00
Peter Hutterer
c72f27b4c2 eis: switch to eis_device_allow_capability()
The previous approach would implicitly allow any capability not known to the
server. Switch instead to requiring an explicit 'ok' for any capability the
server wants to support.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-17 05:29:01 +00:00
Peter Hutterer
31800cf870 util: make the OBJECT_IMPLEMENT_CREATE no longer static by default
Better for consistency with the other functions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-15 23:23:51 +00:00
Peter Hutterer
4a918d17d8 libeis: namespace the capability-specific getters and setters
Naming scheme is now: ei_device_<capability>_get/set_<what>. So far the
range is the only one where we had to deal with the same thing for two
different capabilities and it's unlikely we'll have to have different keymaps
for different capabilities. But still, let's do this now while it's still
easy.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-28 14:13:56 +10:00
Peter Hutterer
e4840d4523 libei: namespace the capability-specific configure calls
Naming scheme is now: ei_device_<capability>_configure_<what>. So far the
range is the only one where we had to deal with the same thing for two
different capabilities and it's unlikely we'll have to have different keymaps
for different capabilities. But still, let's do this now while it's still
easy.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-28 14:13:53 +10:00
Peter Hutterer
ac42578811 replace the fallthrough comments with __attribute__((fallthrough))
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-26 11:00:50 +10:00
Peter Hutterer
b49e4a48c9 test: move the sources and io tests to the util unit tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-25 11:37:18 +10:00
Peter Hutterer
bde5b37acf Include stddef.h for size_t
And add the minimal build tests to make sure we build and link

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 13:01:37 +10:00
Peter Hutterer
e238a5d049 util: fix receiving of multiple fds
Initial implementation only handled this correctly if the fds were over
multiple message headers, not multiple fds in the same message header.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 11:01:01 +10:00
Peter Hutterer
575943e744 test: add another dispatch for the suspend test
In case the RESUMED isn't written on the wire yet (or it's written with
sendmsg and thus a separate message on its own) we don't have the RESUMED
ready for us yet. Let's call another dispatch to make sure it's processed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 15:25:27 +10:00
Peter Hutterer
d160f6c7af test: enable debug logging again
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 15:25:27 +10:00
Peter Hutterer
dabd48c028 util: add fd passing to the iobufs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 14:51:53 +10:00
Peter Hutterer
56ca4b4ac7 util: add sending and receiving fds to the io utilities
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 11:49:53 +10:00