platform/upstream/libinput.git
10 years agoevdev-touchpad: don't post motion events for 0/0 deltas
Peter Hutterer [Fri, 7 Feb 2014 01:09:08 +0000 (11:09 +1000)]
evdev-touchpad: don't post motion events for 0/0 deltas

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoevdev-touchpad: replace some numbers with a #define
Peter Hutterer [Fri, 7 Feb 2014 00:32:03 +0000 (10:32 +1000)]
evdev-touchpad: replace some numbers with a #define

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoutil: add min/max macros
Peter Hutterer [Thu, 6 Feb 2014 05:26:02 +0000 (15:26 +1000)]
util: add min/max macros

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMake it possible to have persistent libinput_seat instances
Jonas Ådahl [Mon, 10 Feb 2014 01:40:55 +0000 (11:40 +1000)]
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>
10 years agoevdev: restore EVDEV_UNHANDLED_DEVICE error code
Peter Hutterer [Mon, 10 Feb 2014 05:40:49 +0000 (15:40 +1000)]
evdev: restore EVDEV_UNHANDLED_DEVICE error code

If we don't have capabilities we can deal with, return a different
error so the backends can handle it separately (they already do).

Signe-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: Add tests for adding/removing devices
Peter Hutterer [Thu, 6 Feb 2014 00:05:29 +0000 (10:05 +1000)]
test: Add tests for adding/removing devices

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoudev: rename create_from_udev to udev_create_for_seat
Peter Hutterer [Wed, 29 Jan 2014 05:35:20 +0000 (15:35 +1000)]
udev: rename create_from_udev to udev_create_for_seat

Maintain proper namespacing rename the backend-specific calls to
libinput_<backend>_<foo>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agopath: add libinput_path_create_context instead of libinput_create_from_path
Peter Hutterer [Wed, 29 Jan 2014 05:38:48 +0000 (15:38 +1000)]
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>
10 years agopath: add libinput_path_add_device() and libinput_path_remove_device()
Peter Hutterer [Wed, 29 Jan 2014 06:37:45 +0000 (16:37 +1000)]
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>
10 years agopath: modify backend to allow for more than one device
Peter Hutterer [Wed, 29 Jan 2014 05:57:53 +0000 (15:57 +1000)]
path: modify backend to allow for more than one device

The previous path backend created a libinput context attached to a single
device. This is insufficient when we need to use cross-device functionality.
One example of this cross-device functionality include disabling a touchpad
while the trackstick is in use (Lenovo T440 and related models).

This patch merely adds the infrastructure to support multiple devices for a
path backend. Follow-up patches add the function calls to add and remove
devices. This is needed by Xorg input drivers that still make use of the
server's device hotplug mechanisms but want to otherwise use libinput.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoRevert "evdev: restore EVDEV_UNHANDLED_DEVICE error code"
Peter Hutterer [Mon, 10 Feb 2014 01:22:39 +0000 (11:22 +1000)]
Revert "evdev: restore EVDEV_UNHANDLED_DEVICE error code"

This reverts commit e8c20c7241d29aa3b725e6a03d52656cafacf0e0.

Ooops, bad rebase. This accesses the device after it was already destroyed
which is not the intent of the patch.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoevdev: restore EVDEV_UNHANDLED_DEVICE error code
Peter Hutterer [Wed, 5 Feb 2014 23:33:26 +0000 (09:33 +1000)]
evdev: restore EVDEV_UNHANDLED_DEVICE error code

If we don't have capabilities we can deal with, return a different error so
the backends can handle it separately (they already do).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoevdev: if mtdev failed to open, fail to init the device
Peter Hutterer [Wed, 5 Feb 2014 23:26:00 +0000 (09:26 +1000)]
evdev: if mtdev failed to open, fail to init the device

We can't handle protocol A devices properly without mtdev, so skip the device
altogether.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agopath: add error handling for failing to create a seat
Peter Hutterer [Wed, 29 Jan 2014 06:08:54 +0000 (16:08 +1000)]
path: add error handling for failing to create a seat

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMove opening and closing the device fd into evdev.c
Peter Hutterer [Thu, 30 Jan 2014 04:54:31 +0000 (14:54 +1000)]
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>
10 years agotest: plug a memory leak, all events need to be destroyed
Peter Hutterer [Mon, 3 Feb 2014 04:23:38 +0000 (14:23 +1000)]
test: plug a memory leak, all events need to be destroyed

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoevdev: Fix absolute coordinate transform formula
Jonas Ådahl [Mon, 3 Feb 2014 22:35:24 +0000 (23:35 +0100)]
evdev: Fix absolute coordinate transform formula

Since the device min/max x/y coordinates are inclusive, to get the
width/height one need to add one to (min x/y - max x/y).

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoRemove mention of delta coordinates having device specific direction
Jonas Ådahl [Tue, 28 Jan 2014 21:50:26 +0000 (22:50 +0100)]
Remove mention of delta coordinates having device specific direction

The event represent pointer motions on a screen, so this information is
unnecessary. It could also be confused for meaning the provided
coordinate's direction being device specific.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoReplace output screen size callback with transform helpers
Jonas Ådahl [Sat, 25 Jan 2014 10:53:53 +0000 (11:53 +0100)]
Replace output screen size callback with transform helpers

Instead of automatically transforming absolute coordinates of touch and
pointer events to screen coordinates, the user now uses the corresponding
transform helper function. This means the coordinates returned by
libinput_event_pointer_get_absolute_x(),
libinput_event_pointer_get_absolute_y(), libinput_touch_get_x() and
libinput_touch_get_y() has changed from being in output screen coordinate
space to being in device specific coordinate space.

For example, where one before would call libinput_event_touch_get_x(event),
one now calls libinput_event_touch_get_x_transformed(event, output_width).

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agopath: fix inconsistent use of devnode vs input->path
Peter Hutterer [Thu, 16 Jan 2014 01:25:26 +0000 (11:25 +1000)]
path: fix inconsistent use of devnode vs input->path

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: don't leak open/closed counts into the next test
Peter Hutterer [Thu, 16 Jan 2014 00:56:01 +0000 (10:56 +1000)]
test: don't leak open/closed counts into the next test

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotools: add a tool for basic event debugging
Peter Hutterer [Tue, 28 Jan 2014 01:25:40 +0000 (11:25 +1000)]
tools: add a tool for basic event debugging

Simply prints the various events to make it easier to check what's coming out
of libinput. Works for --udev (the default) or for --device /dev/input/event0.
Example output:

event7  DEVICE_ADDED seat0 default
event8  DEVICE_ADDED seat0 default
event4  POINTER_BUTTON  +1.35s 272 pressed
event5  POINTER_MOTION  +2.31s  -3.00/  2.00

Time is displayed relative to the starting time.

Note: statically linked for easier debugging, but we don't distribute it
(yet) anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
10 years agotest: Make sure the sysname of a device is correct
Peter Hutterer [Tue, 28 Jan 2014 05:54:34 +0000 (15:54 +1000)]
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>
10 years agopath: print error when failing to open a device
Peter Hutterer [Wed, 29 Jan 2014 01:37:47 +0000 (11:37 +1000)]
path: print error when failing to open a device

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
10 years agopath: store the sysname, not the syspath, in the device
Peter Hutterer [Tue, 28 Jan 2014 05:46:37 +0000 (15:46 +1000)]
path: store the sysname, not the syspath, in the device

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoAdd COPYING file
Peter Hutterer [Tue, 28 Jan 2014 21:28:03 +0000 (07:28 +1000)]
Add COPYING file

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevdev: Don't queue touch events when no touch capability is reported
Jonas Ådahl [Mon, 27 Jan 2014 22:33:46 +0000 (23:33 +0100)]
evdev: Don't queue touch events when no touch capability is reported

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevdev: Don't report touch devices with buttons as actual touch devices
Jonas Ådahl [Mon, 27 Jan 2014 22:27:16 +0000 (23:27 +0100)]
evdev: Don't report touch devices with buttons as actual touch devices

This was a detail of the original version of the commit "evdev: Remove
EVDEV_TOUCH and with it evdev_device->caps" that got lost during porting.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoDocument the LIBINPUT_EVENT_NONE event type
Jonas Ådahl [Sat, 25 Jan 2014 10:52:33 +0000 (11:52 +0100)]
Document the LIBINPUT_EVENT_NONE event type

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoAllow initial device configuration after receiving DEVICE_ADDED event
Jonas Ådahl [Sat, 25 Jan 2014 10:46:55 +0000 (11:46 +0100)]
Allow initial device configuration after receiving DEVICE_ADDED event

By specifying that a device will not be read until the next time the
user calls libinput_dispatch(), if data is available, it will allow for
setting up initial configuration, such as tap button, output screen
size, acceleration parameters, etc.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoFix some coding style inconsistencies
Jonas Ådahl [Sat, 25 Jan 2014 10:33:09 +0000 (11:33 +0100)]
Fix some coding style inconsistencies

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevdev: Make evdev manage its seat reference
Jonas Ådahl [Wed, 22 Jan 2014 22:48:39 +0000 (23:48 +0100)]
evdev: Make evdev manage its seat reference

Before the seat reference would be decreased when a device was removed.
This could cause libinput_device_get_seat() to potentially return an
invalid pointer when a device was removed, its seat unreferenced and
destryoed.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoRemove redundant device pointer from device notify event
Jonas Ådahl [Wed, 22 Jan 2014 22:59:05 +0000 (23:59 +0100)]
Remove redundant device pointer from device notify event

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoSimplify device reference counting of events
Jonas Ådahl [Wed, 22 Jan 2014 22:45:44 +0000 (23:45 +0100)]
Simplify device reference counting of events

This also makes DEVICE_ADDED/REMOVED events own a reference, which is
necessary to not have libinput_event_get_device() potentially returning
an invalid pointer.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevdev: Make error handling more consistent
Jonas Ådahl [Wed, 22 Jan 2014 22:43:45 +0000 (23:43 +0100)]
evdev: Make error handling more consistent

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agotest: add a simple touch test
Peter Hutterer [Wed, 22 Jan 2014 00:34:11 +0000 (10:34 +1000)]
test: add a simple touch test

Currently testing for touch frame events only

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: add basic pointer motion and button test
Peter Hutterer [Tue, 21 Jan 2014 04:17:01 +0000 (14:17 +1000)]
test: add basic pointer motion and button test

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: add a wacom touch devices (absolute touchscreen)
Peter Hutterer [Tue, 21 Jan 2014 23:58:43 +0000 (09:58 +1000)]
test: add a wacom touch devices (absolute touchscreen)

This means we do have to provide the get_current_screen_dimensions() call in
litest now, just hardcode it to 1024x768.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: Add a basic mouse test device
Peter Hutterer [Tue, 21 Jan 2014 05:18:09 +0000 (15:18 +1000)]
test: Add a basic mouse test device

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: Add a common helper function to drain all current events
Peter Hutterer [Wed, 22 Jan 2014 01:20:50 +0000 (11:20 +1000)]
test: Add a common helper function to drain all current events

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoevdev: don't ignore scroll events with a value greater than 1/-1
Peter Hutterer [Tue, 21 Jan 2014 05:48:06 +0000 (15:48 +1000)]
evdev: don't ignore scroll events with a value greater than 1/-1

Higher values than 1 or -1 are legitimate on some devices, though not all mice
send wheel events other than 1/-1.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agopath: get ID_SEAT and WL_SEAT from udev for the device node
Peter Hutterer [Tue, 21 Jan 2014 02:03:47 +0000 (12:03 +1000)]
path: get ID_SEAT and WL_SEAT from udev for the device node

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDrop event classes
Peter Hutterer [Tue, 21 Jan 2014 03:56:12 +0000 (13:56 +1000)]
Drop event classes

There are now only two event classes and only two users of the event class.
It's easier to use the event type directly to see which event has references
and which one doesn't.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoPromote touch frames to top-level events
Peter Hutterer [Fri, 20 Dec 2013 00:15:00 +0000 (10:15 +1000)]
Promote touch frames to top-level events

These events are not a state of a single touchpoints but rather a notification
that all touchpoints finished processing. As such, they should have their own
type.

And make sure we actually send them when needed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoProvide accessors to retrieve the right event type
Peter Hutterer [Thu, 19 Dec 2013 23:22:32 +0000 (09:22 +1000)]
Provide accessors to retrieve the right event type

Slightly enhances the type-safety. A caller may now do something along the
lines of

struct libinput_event_pointer *ptrev;
ptrev = libinput_event_get_pointer_event(event);

if (!ptrev)
   oops, that wasn't a pointer event

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd documentation for the various events
Peter Hutterer [Thu, 19 Dec 2013 07:50:49 +0000 (17:50 +1000)]
Add documentation for the various events

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agozalloc all events to make sure we have defined defaults
Peter Hutterer [Wed, 22 Jan 2014 01:01:24 +0000 (11:01 +1000)]
zalloc all events to make sure we have defined defaults

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoReduce touch events to a single event type
Peter Hutterer [Thu, 19 Dec 2013 07:16:19 +0000 (17:16 +1000)]
Reduce touch events to a single event type

No real effect since we're hiding the actual touch events through the touch
type.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoReduce pointer events to one single type
Peter Hutterer [Thu, 19 Dec 2013 03:15:28 +0000 (13:15 +1000)]
Reduce pointer events to one single type

The event type itself says enough about the actual event type, we don't need
to have separate structs for every type.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoReduce keyboard events to one single type
Peter Hutterer [Thu, 19 Dec 2013 06:40:48 +0000 (16:40 +1000)]
Reduce keyboard events to one single type

Provide one top-level event for keyboard events: libinput_event_keyboard. The
event type specifies which subtype the event is anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoImprove namespacing of event types
Peter Hutterer [Thu, 19 Dec 2013 02:04:24 +0000 (12:04 +1000)]
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>
10 years agoMerge the device added/removed events into a single device notify event
Peter Hutterer [Wed, 15 Jan 2014 07:10:30 +0000 (17:10 +1000)]
Merge the device added/removed events into a single device notify event

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDrop libinput_event_get_target()
Peter Hutterer [Thu, 19 Dec 2013 01:42:55 +0000 (11:42 +1000)]
Drop libinput_event_get_target()

Replaced by specific accessor functions for context, seat and device. This
obsoletes the internal target as well, we just direcly ref the element we need
to instead of temporarily storing it in the target.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd a generic libinput_event_get_device() function
Peter Hutterer [Fri, 17 Jan 2014 07:59:30 +0000 (17:59 +1000)]
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>
10 years agoSplit seats into having a physical and a logical name
Peter Hutterer [Wed, 15 Jan 2014 07:04:00 +0000 (17:04 +1000)]
Split seats into having a physical and a logical name

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDrop seat events
Peter Hutterer [Wed, 15 Jan 2014 06:31:29 +0000 (16:31 +1000)]
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>
10 years agoAdd libinput_event_get_context()
Peter Hutterer [Thu, 19 Dec 2013 01:22:53 +0000 (11:22 +1000)]
Add libinput_event_get_context()

Add a function to retrieve the libinput context from any event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoudev: Drop unused seat_name in struct udev_seat
Peter Hutterer [Wed, 15 Jan 2014 06:57:30 +0000 (16:57 +1000)]
udev: Drop unused seat_name in struct udev_seat

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: Remove short option and fail on invalid options
Jonas Ådahl [Wed, 15 Jan 2014 22:24:21 +0000 (23:24 +0100)]
test: Remove short option and fail on invalid options

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agotest: Add udev suspend->resume test
Jonas Ådahl [Wed, 15 Jan 2014 20:33:00 +0000 (21:33 +0100)]
test: Add udev suspend->resume test

Tests that suspend removes devices and that resume rediscovers them.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agotest: Fix optstring in getopt_long call
Jonas Ådahl [Wed, 15 Jan 2014 20:11:51 +0000 (21:11 +0100)]
test: Fix optstring in getopt_long call

Was missing the "l".

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agotest: udev suspend tests
Peter Hutterer [Wed, 8 Jan 2014 07:39:27 +0000 (17:39 +1000)]
test: udev suspend tests

10 years agotest: path suspend tests
Peter Hutterer [Wed, 8 Jan 2014 07:39:16 +0000 (17:39 +1000)]
test: path suspend tests

10 years agotest: add tests for libinput_create_from_path
Peter Hutterer [Tue, 10 Dec 2013 03:30:52 +0000 (13:30 +1000)]
test: add tests for libinput_create_from_path

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
squashme path test

10 years agotest: add a couple of tests for the udev-seat backend
Peter Hutterer [Mon, 9 Dec 2013 06:36:11 +0000 (16:36 +1000)]
test: add a couple of tests for the udev-seat backend

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd a device test suite
Peter Hutterer [Fri, 6 Dec 2013 05:02:11 +0000 (15:02 +1000)]
Add a device test suite

A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.

The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.

Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.

For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.

check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.

litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);

adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
   "foo:bar", "trackpoint"
   "foo:bar", "clickpad"
   ...

Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).

The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: add test for minimal linker flags
Peter Hutterer [Tue, 10 Dec 2013 22:20:59 +0000 (08:20 +1000)]
test: add test for minimal linker flags

The most basic program using libinput should only need to link against -linput
and get the rest resolved automatically.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: add a build-test for -pedantic
Peter Hutterer [Fri, 6 Dec 2013 04:18:39 +0000 (14:18 +1000)]
test: add a build-test for -pedantic

We don't build with -pedantic, but a caller may try to actually stick to the
c99 standard, so let's make sure our public header doesn't cause any
issues there.

Likewise, make sure that our header compiles with GNU C90.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd the framework for a test suite
Peter Hutterer [Fri, 6 Dec 2013 04:17:35 +0000 (14:17 +1000)]
Add the framework for a test suite

Just the scaffolding, no actual tests just yet

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMake sure our public header compiles with -pedantic
Peter Hutterer [Fri, 6 Dec 2013 04:29:01 +0000 (14:29 +1000)]
Make sure our public header compiles with -pedantic

We don't use -pedantic, but a user of libinput may so let's make sure we don't
fail.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agogitignore: ignore .swp files
Peter Hutterer [Fri, 10 Jan 2014 03:33:02 +0000 (13:33 +1000)]
gitignore: ignore .swp files

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd libinput_next_event_type()
Peter Hutterer [Fri, 13 Dec 2013 07:58:50 +0000 (17:58 +1000)]
Add libinput_next_event_type()

Returns the event type of the next event pending in the queue. For systems
that have the device init state separate from the actual event procesing
(read: xorg drivers) we need to be able to peek at the next event type to
check for the end of any initialization events (seat/device added) and the
beginning of actual device input events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd LIBEVENT_EVENT_NONE
Peter Hutterer [Fri, 13 Dec 2013 07:49:38 +0000 (17:49 +1000)]
Add LIBEVENT_EVENT_NONE

This event type is needed to notify callers that there is currently no
event waiting (in a follow-up patch). Also, it it avoids true/false
inconsistencies on event types (LIBINPUT_EVENT_ADDED_SEAT would otherwise be
the only FALSE event). While that's not technically necessary, it may prevent
the odd bug further down the road.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDrop capability events
Peter Hutterer [Thu, 9 Jan 2014 03:12:23 +0000 (13:12 +1000)]
Drop capability events

We don't really support devices changing capabilities at runtime. The kernel
has no ability to tell us when this happens on an already-opened device and
the few devices that can literally change physical capabilities (e.g. the
wiimote) open up extra kernel devices instead of modifying the existing one.

Thus, we don't need to notify about devices changing capabilities.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd libinput_create_from_path
Peter Hutterer [Tue, 10 Dec 2013 03:20:36 +0000 (13:20 +1000)]
Add libinput_create_from_path

Hooking libinput up to udev isn't always possible, especially if libinput were
to be used in the X server which already has the udev handling built-in.
Add an option to create a context from a path.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoSuspend libinput before destroying it
Peter Hutterer [Tue, 7 Jan 2014 04:54:55 +0000 (14:54 +1000)]
Suspend libinput before destroying it

libinput_suspend() already causes the fds to be closed, devices and seats to
be removed, etc. Call it before libinput_destroy() to reduce the
backend-specific code.

No real functional change, the udev backend already did this anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoudev: notify about a removed seat when the last device is removed
Peter Hutterer [Mon, 23 Dec 2013 04:16:03 +0000 (14:16 +1000)]
udev: notify about a removed seat when the last device is removed

When the last device is removed from a seat, destroy the seat.
This guarantees seat removal events on libinput_suspend() as well.

Note that the seat must be manually unlinked, we can't rely on the unlinking
in libinput_seat_destroy. After the event, the seat's refcount is always > 1,
so the seat will live on until the event is destroyed. We need to make sure
it's not in the list anymore though.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoudev: Refcount the seat for each device
Peter Hutterer [Mon, 23 Dec 2013 04:10:56 +0000 (14:10 +1000)]
udev: Refcount the seat for each device

Use the seat's internal refcounting to up the reference each time we have a
device using it. This fixes the issue with seats being created but never
actually removed by anything.

udev_seat_get_named() will now return a seat with refcount 1 for a newly
created seat, or just up the refcount for the seat if it already exists.

This requires that the ADDED_SEAT and REMOVED_SEAT events up the refcount of
the seat as well: a device may be removed before the event is processed,
without the refcount the seat would be destroyed (if it's the last device on
the seat).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAbstract the backend interface away
Peter Hutterer [Fri, 13 Dec 2013 01:37:31 +0000 (11:37 +1000)]
Abstract the backend interface away

Remove the fixed calls into the udev backend and provide a basic interface
instead that allows other backends to hook into device/seat creation. This
enables multiple backends, specifically a path-based backend that is needed
for X.Org drivers.

This patch should have no visible functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDrop the destroyed sources list on libinput_destroy()
Peter Hutterer [Tue, 7 Jan 2014 05:45:55 +0000 (15:45 +1000)]
Drop the destroyed sources list on libinput_destroy()

==2772== 40 bytes in 1 blocks are definitely lost in loss record 3 of 4
==2772==    at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==2772==    by 0x405EC7: libinput_add_fd (libinput.c:335)
==2772==    by 0x40B346: udev_input_enable (udev-seat.c:268)
==2772==    by 0x40B5E7: libinput_create_from_udev (udev-seat.c:369)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAllow libinput_destroy() on a NULL pointer
Peter Hutterer [Tue, 24 Dec 2013 01:00:37 +0000 (11:00 +1000)]
Allow libinput_destroy() on a NULL pointer

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoudev: plug leak when double-resuming
Peter Hutterer [Wed, 8 Jan 2014 02:53:46 +0000 (12:53 +1000)]
udev: plug leak when double-resuming

Leak when calling
  libinput_suspend();
  libinput_resume();
  libinput_resume();

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd two asserts to avoid underrunning the seat/device refcount
Peter Hutterer [Wed, 8 Jan 2014 06:40:14 +0000 (16:40 +1000)]
Add two asserts to avoid underrunning the seat/device refcount

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAlways allocate an event queue
Peter Hutterer [Tue, 24 Dec 2013 03:50:10 +0000 (13:50 +1000)]
Always allocate an event queue

On the typical setup we have at least 3 events pending as soon as we hook it
up (seat added, device added, capability). In the udev case we get up to > 64
events without even having input events on my laptop with only two extra
devices connected. So always allocate an event buffer to avoid spurious
resizing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDon't access event buffer after realloc
Peter Hutterer [Tue, 24 Dec 2013 03:46:20 +0000 (13:46 +1000)]
Don't access event buffer after realloc

realloc() may free the original event buffer, don't access it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agogitignore: ignore ctags files
Peter Hutterer [Tue, 24 Dec 2013 00:52:28 +0000 (10:52 +1000)]
gitignore: ignore ctags files

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agogitignore: generalise .libs/ and .deps/
Peter Hutterer [Tue, 24 Dec 2013 00:51:41 +0000 (10:51 +1000)]
gitignore: generalise .libs/ and .deps/

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoRemove duplicate gitignore entries
Peter Hutterer [Tue, 24 Dec 2013 00:51:17 +0000 (10:51 +1000)]
Remove duplicate gitignore entries

Already covered by a global rule

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDestroy associated reference counted objects when destroying context
Jonas Ådahl [Tue, 31 Dec 2013 15:11:03 +0000 (16:11 +0100)]
Destroy associated reference counted objects when destroying context

This avoids issues with device and seat objects depending on a valid
context.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoudev-seat: Don't notify about removal when destroying context
Jonas Ådahl [Tue, 31 Dec 2013 13:45:50 +0000 (14:45 +0100)]
udev-seat: Don't notify about removal when destroying context

As events will just be destroyed before leaving the libinput scope
during destruction, don't waste time on queueing them.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoDestroy unprocessed events properly when destroying context
Jonas Ådahl [Mon, 30 Dec 2013 21:11:33 +0000 (22:11 +0100)]
Destroy unprocessed events properly when destroying context

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoDon't return error when dispatching didn't queue any event
Jonas Ådahl [Mon, 30 Dec 2013 21:08:35 +0000 (22:08 +0100)]
Don't return error when dispatching didn't queue any event

As reading from timers or evdev does not necessarily mean an input
event is queued and ready to be retrieved with libinput_get_event(),
don't report such behaviour as an error.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevdev: Drop joystick rejection heurstics
Kristian Høgsberg [Mon, 16 Dec 2013 23:57:53 +0000 (15:57 -0800)]
evdev: Drop joystick rejection heurstics

We now no longer add joysticks at all.  They show up as absolute motion
devices without has_button, so we don't add them as a pointer.  We may add
a keyboard for the keyboard-style keys, but that's fine.  With the previous
commit, we no longer generate spurious absolute pointer motion for the abs
axes.

https://bugs.freedesktop.org/show_bug.cgi?id=71687

10 years agoevdev: Reject absolute motion if we're not a pointer or a touch device
Kristian Høgsberg [Mon, 16 Dec 2013 23:51:22 +0000 (15:51 -0800)]
evdev: Reject absolute motion if we're not a pointer or a touch device

Some joysticks have certain buttons that acts keyboard keys.  As such,
we'll reconize them as keyboards but not pointers.  In that case, don't
send pointer motion events when we get absolute joystick events.

10 years agoevdev: Drop obsolete accelerometer reject rule
Kristian Høgsberg [Mon, 16 Dec 2013 23:37:16 +0000 (15:37 -0800)]
evdev: Drop obsolete accelerometer reject rule

This rule triggers for devices with an ABS_X/Y evaluators and no
keyboard or multitouch events.  There is no way we would ever add such
a device as a pointer, keyboard or touch device anyway.  A pointer
device requires has_button (in which case the !has_key condtion would
fail); a keyboard device would also mean !has_key is false and a touch
screen device implies that !device->is_mt is false.

10 years agoevdev: Remove EVDEV_TOUCH and with it evdev_device->caps
Kristian Høgsberg [Mon, 16 Dec 2013 23:19:30 +0000 (15:19 -0800)]
evdev: Remove EVDEV_TOUCH and with it evdev_device->caps

We now keep all the configuration intermediate results inside
evdev_configure_device() and the result is device->seat_caps.

10 years agoevdev: Use a has_keyboard flag instead of EVDEV_KEYBOARD bit
Kristian Høgsberg [Mon, 16 Dec 2013 23:07:59 +0000 (15:07 -0800)]
evdev: Use a has_keyboard flag instead of EVDEV_KEYBOARD bit

10 years agoevdev: Replace EVDEV_BUTTON with local has_button flag
Kristian Høgsberg [Mon, 16 Dec 2013 22:43:29 +0000 (14:43 -0800)]
evdev: Replace EVDEV_BUTTON with local has_button flag

10 years agoevdev: Replace EVDEV_MOTION_ABS with local has_abs flag
Kristian Høgsberg [Mon, 16 Dec 2013 21:55:48 +0000 (13:55 -0800)]
evdev: Replace EVDEV_MOTION_ABS with local has_abs flag

10 years agoevdev: Use has_abs only for ABS_X and ABS_Y, introduce has_mt for MT events
Kristian Høgsberg [Mon, 16 Dec 2013 21:42:40 +0000 (13:42 -0800)]
evdev: Use has_abs only for ABS_X and ABS_Y, introduce has_mt for MT events

We split up has_abs into plain ABS_X/Y and MT events, but this shouldn't
introduce any logic changes.