Commit graph

24 commits

Author SHA1 Message Date
Peter Hutterer
3927b63207 cosmetic: more duplicate empty line removal
This should be it now, finally...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-02 16:48:51 +10:00
Peter Hutterer
6e6cca47af Add libinput_set_user_data
Previously, the pointer could only be passed into the context on creation
time and was immutable after that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-23 14:49:39 +10:00
Peter Hutterer
348cff5701 test: add seat changing tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-11-25 16:34:22 +10:00
Jonas Ådahl
4be59a972a test: Use only one test device for some udev and path tests
Some tests in test/path.c and test/udev.c are not dependent on
device behaviour but rather managing of device lifetime etc. Run those
tests only once with only one device, resulting more or less the same
code coverage but shorter run time.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-18 22:35:19 +02:00
Jonas Ådahl
ea1d2d6348 test/path: Avoid creating ignored test devices
Some tests doesn't use or doesn't need to use the test device
automatically created when adding a test case for certain types of
devices. For these tests, to shorten test run time, don't create the
test devices that would be ignored.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-07-22 20:36:37 +02:00
Peter Hutterer
125e98a1f8 style fix: Remove duplicate empty lines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-07-22 09:00:45 +10:00
Jonas Ådahl
faab25c25c Make context reference counted
Instead of only allowing one owner keeping a libinput context alive,
make context reference counted, replacing libinput_destroy() with
libinput_unref() while adding another function libinput_ref().

Even though there might not be any current use cases, it doesn't mean we
should hard code this usage model in the API. The old behaviour can be
emulated by never calling libinput_ref() while replacing
libinput_destroy() with libinput_unref().

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-25 10:27:03 +10:00
Peter Hutterer
1db5866cee test: fix a path test
Test with the right interface, otherwise checking to make sure we didn't call
open on any device is a bit pointless.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-13 11:48:53 +10:00
Peter Hutterer
7149cc9392 test: use check's strcmp API instead of strcmp
Prints out the strings on failure - easier for debugging

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-11 09:43:52 +10:00
Peter Hutterer
04d52d718f test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.

The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.

Both functions abort on failure, so the caller does not need to check the
return value.

Example code for creating a rel device:

struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
                                     EV_REL, REL_X,
                                     EV_REL, REL_Y,
                                     EV_KEY, BTN_LEFT,
                                     INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
                                     -1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-04-08 15:07:02 +10:00
Jonas Ådahl
b34139c9e7 Make it possible to have persistent libinput_seat instances
With this patch, a user can keep a reference to a libinput_seat
instance, which will cause the seat to never be unlinked from the
libinput context nor destroyed.

Previously, a when the last device of a seat was removed, the seat was
unlinked and if a new device was discovered with a previously empty seat
a new seat instance would always be created, meaning two potential seat
instances with identical physical and logical seat name pairs.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 22:28:46 +01:00
Peter Hutterer
b069228937 test: Add tests for adding/removing devices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 11:23:36 +10:00
Peter Hutterer
606249f91c path: add libinput_path_create_context instead of libinput_create_from_path
Creates an empty context that is not hooked up to a device. Callers can then
add and remove devices to this context using libinput_path_add_device() and
libinput_path_remove_device().

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 11:23:36 +10:00
Peter Hutterer
69dcea11b9 path: add libinput_path_add_device() and libinput_path_remove_device()
This allows multiple devices to share a single libinput context. The new
function returns the newly added device immediately. Unlike the udev seat
where devices may or may not be added - over the lifetime of the seat - a
path-based backend knows immediately if device exists or doesn't exist.

Returning the device is required by callers that have the event processing
separate from adding devices - by the time we have the DEVICE_ADDED event in
the queue we may have other events to process first. And the DEVICE_ADDED
event won't easily link to the path we gave it anyway, so it's hard to figure
out which DEVICE_ADDED event corresponds to the new device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 11:23:36 +10:00
Peter Hutterer
1901449871 Move opening and closing the device fd into evdev.c
evdev_device_remove() already calls close(device->fd). Move the
close_restricted call there to avoid one privileged call in the backend and
one in the device. And move the open_restricted() into the evdev device too to
reduce the duplicated code in the two backends.

Update to one of the tests: since we'd now fail getting the device node from
the invalid /tmp path, the open_func_count is 0.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-06 09:16:43 +10:00
Peter Hutterer
0d879fd239 test: plug a memory leak, all events need to be destroyed
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-06 08:09:34 +10:00
Peter Hutterer
db2274eaad test: don't leak open/closed counts into the next test
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-31 15:00:17 +10:00
Peter Hutterer
20416ae4b7 test: Make sure the sysname of a device is correct
Currently this means start with "event" and don't contain /.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-31 14:57:18 +10:00
Peter Hutterer
54db6527ae Improve namespacing of event types
Now that the target of an event isn't exposed to the caller anymore, the
namespacing can be associated with a more intuitive one.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-21 22:50:59 +01:00
Peter Hutterer
60d46e6bd7 Add a generic libinput_event_get_device() function
After dropping seat evens, all events are now are associated with a device, so
provide a generic accessor function and drop the custom ones.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-21 22:50:58 +01:00
Peter Hutterer
c29a8e8093 Split seats into having a physical and a logical name
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-17 18:17:45 +10:00
Peter Hutterer
5b5b6bca06 Drop seat events
seats are more a compositor concept than a concept of the input library. All
devices in a libinput context are associated with the seat given on creation
of the seat (maps to ID_SEAT in udev for the udev backend).

A logical seat may be assigned to a device (e.g. WL_SEAT) but this does not
necessarily map to the creation of the seat in the compositor.
Drop the seat events but keep seat objects around so that the caller can still
identify which seat a device belongs to.

If the libinput_seat_unref() in the udev backend destroys the seat, the device
list of that seat is invalid and we'd be accessing already freed bytes. To
avoid this, ref the seat before the device removal loop, then unref it once
we're done - that unref then may trigger the actual removal of the seat.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-17 18:17:11 +10:00
Peter Hutterer
69d89ddcc2 test: path suspend tests 2014-01-15 12:03:25 +10:00
Peter Hutterer
caaf170f4d test: add tests for libinput_create_from_path
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

squashme path test
2014-01-15 12:03:25 +10:00