platform/upstream/libinput.git
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.

10 years agoevdev: Drop EVDEV_MOTION_REL flag
Kristian Høgsberg [Mon, 16 Dec 2013 19:25:19 +0000 (11:25 -0800)]
evdev: Drop EVDEV_MOTION_REL flag

This is only used inside evdev_configure_device() and we now use a local
has_rel flag instead.

10 years agoevdev: Combine evdev_handle_device() and evdev_configure_device()
Kristian Høgsberg [Mon, 16 Dec 2013 19:01:56 +0000 (11:01 -0800)]
evdev: Combine evdev_handle_device() and evdev_configure_device()

We split the device probing and idenfication somewhat arbitrarily between
these two functions.  This commit combines them into one.  Return of -1
indicates error, 0 success, but succesful probing can return a device
with device->caps == 0, which means we don't handle the device.

10 years agodoc: extract static members as well
Peter Hutterer [Thu, 19 Dec 2013 01:06:40 +0000 (11:06 +1000)]
doc: extract static members as well

We only run doxygen over the public headers, so if we have a static function
in those make sure they show up.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDocumentation typo fix
Peter Hutterer [Fri, 13 Dec 2013 07:50:49 +0000 (17:50 +1000)]
Documentation typo fix

10 years agoFix typo in comment
Peter Hutterer [Fri, 13 Dec 2013 04:40:33 +0000 (14:40 +1000)]
Fix typo in comment

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDocument the open/close_restricted interface
Peter Hutterer [Fri, 13 Dec 2013 01:04:01 +0000 (11:04 +1000)]
Document the open/close_restricted interface

Specifically, document that it needs to return a negative errno on failure.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd libudev and -lm to Requires.private
Peter Hutterer [Tue, 10 Dec 2013 21:27:02 +0000 (07:27 +1000)]
Add libudev and -lm to Requires.private

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd -lm to library
Peter Hutterer [Tue, 10 Dec 2013 22:03:33 +0000 (08:03 +1000)]
Add -lm to library

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoudev: print errno if we can't open a device
Peter Hutterer [Fri, 13 Dec 2013 01:05:07 +0000 (11:05 +1000)]
udev: print errno if we can't open a device

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoutil: add ARRAY_FOR_EACH helper
Peter Hutterer [Fri, 6 Dec 2013 04:35:22 +0000 (14:35 +1000)]
util: add ARRAY_FOR_EACH helper

Requires c99, but that's the future.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agodoc: group li_fixed_t into the fixed point functions
Peter Hutterer [Thu, 19 Dec 2013 01:05:29 +0000 (11:05 +1000)]
doc: group li_fixed_t into the fixed point functions

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMove zalloc() up to libinput-util.h
Peter Hutterer [Fri, 6 Dec 2013 04:47:09 +0000 (14:47 +1000)]
Move zalloc() up to libinput-util.h

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoUnref seats and devices in libinput_destroy()
Jonas Ådahl [Mon, 16 Dec 2013 21:52:05 +0000 (22:52 +0100)]
Unref seats and devices in libinput_destroy()

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoudev-seat: Remove unused declaration
Jonas Ådahl [Sun, 15 Dec 2013 20:25:10 +0000 (21:25 +0100)]
udev-seat: Remove unused declaration

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoudev: include libinput-private.h for struct libinput
Peter Hutterer [Tue, 10 Dec 2013 01:39:29 +0000 (11:39 +1000)]
udev: include libinput-private.h for struct libinput

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agofix typo in documentation
Peter Hutterer [Tue, 10 Dec 2013 01:33:29 +0000 (11:33 +1000)]
fix typo in documentation

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoconfigure: require c99
Peter Hutterer [Fri, 6 Dec 2013 04:52:38 +0000 (14:52 +1000)]
configure: require c99

This enables a few nice things that gcc would otherwise not allow.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoudev: fail libinput_create_from_udev for NULL values
Peter Hutterer [Mon, 9 Dec 2013 06:34:49 +0000 (16:34 +1000)]
udev: fail libinput_create_from_udev for NULL values

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoconfigure: add libudev dependency
Peter Hutterer [Mon, 9 Dec 2013 06:21:06 +0000 (16:21 +1000)]
configure: add libudev dependency

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAllow for NULL in libinput_destroy
Peter Hutterer [Mon, 9 Dec 2013 11:27:31 +0000 (21:27 +1000)]
Allow for NULL in libinput_destroy

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAllow for NULL in libevdev_event_destroy
Peter Hutterer [Mon, 9 Dec 2013 11:26:54 +0000 (21:26 +1000)]
Allow for NULL in libevdev_event_destroy

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoIntroduce libinput_device_get_sysname() API
Jonas Ådahl [Sun, 15 Dec 2013 16:50:04 +0000 (17:50 +0100)]
Introduce libinput_device_get_sysname() API

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoExport li_fixed_to_(int|double) converters
Jonas Ådahl [Sun, 15 Dec 2013 16:47:45 +0000 (17:47 +0100)]
Export li_fixed_to_(int|double) converters

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoIntroduce libinput_device_has_capability() API
Jonas Ådahl [Sun, 15 Dec 2013 16:45:02 +0000 (17:45 +0100)]
Introduce libinput_device_has_capability() API

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agodoc: Document basic event accessor functions
Jonas Ådahl [Sun, 8 Dec 2013 15:35:04 +0000 (16:35 +0100)]
doc: Document basic event accessor functions

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoPut libinput_event_destroy() together with other event functions
Jonas Ådahl [Sun, 8 Dec 2013 15:30:13 +0000 (16:30 +0100)]
Put libinput_event_destroy() together with other event functions

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoMake even structs private
Jonas Ådahl [Sun, 8 Dec 2013 11:36:27 +0000 (12:36 +0100)]
Make even structs private

To ease the possibility to extend messages with more information, make
every event struct private, while providing functions used for accessing
the parameters previously found directly in the public structs.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoPut libinput_interface struct below base doxygen group
Jonas Ådahl [Sun, 8 Dec 2013 11:35:40 +0000 (12:35 +0100)]
Put libinput_interface struct below base doxygen group

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoReference count event target struct when applicable
Jonas Ådahl [Sat, 7 Dec 2013 15:41:43 +0000 (16:41 +0100)]
Reference count event target struct when applicable

If the target of an event is a reference counted object, such as
libinput_seat and libinput_device, make events own its own reference to
the object, releasing it when destroyed.

In order to do this, a new API requirement and function are introduced;
libinput_event_destroy(). The user is required to use
libinput_event_destroy() instead of free() after having retrieved an
event using libinput_get_event().

This fixes a race that would be triggered if a device or seat would be
added and removed before the user calling libinput_get_event().

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoRemove unused disabled code
Jonas Ådahl [Sat, 7 Dec 2013 15:01:17 +0000 (16:01 +0100)]
Remove unused disabled code

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agodoc: Clarify that the caller need to free retrieved event
Jonas Ådahl [Sat, 7 Dec 2013 13:06:55 +0000 (14:06 +0100)]
doc: Clarify that the caller need to free retrieved event

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agodoc: hook up doxygen to generate the public API documentation
Peter Hutterer [Thu, 5 Dec 2013 23:58:00 +0000 (09:58 +1000)]
doc: hook up doxygen to generate the public API documentation

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoRename libinput_create_udev to libinput_create_from_udev
Peter Hutterer [Thu, 5 Dec 2013 08:35:32 +0000 (18:35 +1000)]
Rename libinput_create_udev to libinput_create_from_udev

A lot more obvious what it does, it creates a libinput context from a udev
handler (rather than creating the udev handler).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoudev-seat: fix leak when failing to add devices
Peter Hutterer [Thu, 5 Dec 2013 08:37:26 +0000 (18:37 +1000)]
udev-seat: fix leak when failing to add devices

udev-monitor and the udev_monitor_source would leak.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDrop include of evdev.h from evdev.h
Peter Hutterer [Fri, 6 Dec 2013 01:51:09 +0000 (11:51 +1000)]
Drop include of evdev.h from evdev.h

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDrop unused libinput_fd_handle and libinput_fd_callback
Peter Hutterer [Fri, 6 Dec 2013 01:24:09 +0000 (11:24 +1000)]
Drop unused libinput_fd_handle and libinput_fd_callback

Obsolete with ce787552bce26ccac433c7fcf9868d2a5561a0cc

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoevdev: fix memcopy for calibration
Peter Hutterer [Thu, 5 Dec 2013 08:32:36 +0000 (18:32 +1000)]
evdev: fix memcopy for calibration

Function arguments with fixed length are still just pointers, so
sizeof(calibration) here is sizeof(float*), not sizeof(float) * 6.

evdev.c: In function 'evdev_device_calibrate':
evdev.c:693:54: warning: argument to 'sizeof' in 'memcpy' call is the same
  pointer type 'float *' as the destination; expected 'float' or an explicit
  length [-Wsizeof-pointer-memaccess]
  memcpy(device->abs.calibration, calibration, sizeof calibration);

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMove libinput, libinput_seat and libinput_device to the top
Peter Hutterer [Thu, 5 Dec 2013 07:50:47 +0000 (17:50 +1000)]
Move libinput, libinput_seat and libinput_device to the top

Declare all three before they are used.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDeclare libinput_seat explicitly
Peter Hutterer [Thu, 5 Dec 2013 07:50:09 +0000 (17:50 +1000)]
Declare libinput_seat explicitly

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agolibinput_dispatch: return -EAGAIN if no events are ready
Peter Hutterer [Thu, 5 Dec 2013 07:33:47 +0000 (17:33 +1000)]
libinput_dispatch: return -EAGAIN if no events are ready

Notify the caller that no events are currently ready to be processed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agolibinput_dispatch: return negative error number on failure
Peter Hutterer [Thu, 5 Dec 2013 07:26:40 +0000 (17:26 +1000)]
libinput_dispatch: return negative error number on failure

Might as well tell the caller what went wrong without having to worry about
errno.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMake the slots unsigned, the kernel guarantees a base of 0
Peter Hutterer [Thu, 5 Dec 2013 07:04:42 +0000 (17:04 +1000)]
Make the slots unsigned, the kernel guarantees a base of 0

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMake buttons unsigned, there are no negative button numbers
Peter Hutterer [Thu, 5 Dec 2013 07:04:09 +0000 (17:04 +1000)]
Make buttons unsigned, there are no negative button numbers

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoPort udev-seat to be used in libinput
Jonas Ådahl [Sat, 23 Nov 2013 12:04:32 +0000 (13:04 +0100)]
Port udev-seat to be used in libinput

This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.

The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.

Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.

The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().

The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.

There is one known problem with the current API that is the potentially
racy initialization.

The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoutil: Add logging utilities
Jonas Ådahl [Sat, 23 Nov 2013 11:55:44 +0000 (12:55 +0100)]
util: Add logging utilities

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoMerge branch 'master' into udev
Jonas Ådahl [Tue, 19 Nov 2013 21:29:38 +0000 (22:29 +0100)]
Merge branch 'master' into udev

10 years agoAdd interface to libinput object and move screen dimension callback to it
Jonas Ådahl [Sun, 17 Nov 2013 18:31:34 +0000 (19:31 +0100)]
Add interface to libinput object and move screen dimension callback to it

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoUse events instead of callbacks for capability registration
Jonas Ådahl [Sun, 17 Nov 2013 15:59:09 +0000 (16:59 +0100)]
Use events instead of callbacks for capability registration

This commit also introduces a new requirement to
libinput_device_destroy() - libinput_device_terminate() must be called
before libinput_device_destroy() in order to allow the user to dispatch
the events related to a terminating input devices while the device is
still valid.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoIntroduce libinput object managing all input data
Jonas Ådahl [Sun, 17 Nov 2013 10:19:50 +0000 (11:19 +0100)]
Introduce libinput object managing all input data

Instead of having the user manage added and removed fd's as well as the
fd used for creating evdev devices, introduce a libinput object that
itself has an epoll fd.

The user no longer manages multiple fd's per libinput instance, but
instead handles one fd, dispatches libinput when data is available, then
reading events using libinput_get_event().

libinput_event's are now per libinstance, but divided into categories.
So far the only category is device events. Device events are categorized
by the presence of a non-NULL device pointer in the event.

The current API usage should look like:

struct libinput libinput = ...;
struct libinput_event *event;

if (libinput_dispatch(libinput) != 0)
return -1;
while ((event = libinput_get_event(libinput))) {
if (event->device)
process_device_event(event);
free(event);
}

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agosrc/Makefile.a: Fix whitespace
Jonas Ådahl [Sun, 17 Nov 2013 01:38:58 +0000 (02:38 +0100)]
src/Makefile.a: Fix whitespace

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoChange API from using listeners to using an event queue
Jonas Ådahl [Sat, 16 Nov 2013 18:32:46 +0000 (19:32 +0100)]
Change API from using listeners to using an event queue

Instead of having the input drivers invoke user set callbacks during
libinput_device_dispatch() and add_fd callback, let the driver queue
events that the user then reads from using libinput_device_get_event().

A typical use case would be:

struct libinput_device *device = ...;
struct libinput_event *event;

libinput_device_dispatch(device);
while ((event = libinput_device_get_event(device))) {
process_event(device, event);
free(event);
}

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agolauncher: add weston_launcher_close() dummy
David Herrmann [Mon, 21 Oct 2013 22:28:08 +0000 (00:28 +0200)]
launcher: add weston_launcher_close() dummy

If you request a device via weston_launcher_open(), you should now release
it via weston_launcher_close() instead of close(). This is currently not
needed but will be required for logind devices.

10 years agoudev-seat: Repick seat after a new device was added
Jonas Ådahl [Thu, 17 Oct 2013 21:04:08 +0000 (23:04 +0200)]
udev-seat: Repick seat after a new device was added

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agolauncher: Collect launcher state in new struct weston_launcher
Kristian Høgsberg [Tue, 17 Sep 2013 21:41:03 +0000 (14:41 -0700)]
launcher: Collect launcher state in new struct weston_launcher

We're going to add a bit more launcher state, so start out by creating
a new struct weston_launcher we can track it in.

10 years agoAdd more missing config.h includes
Daniel Stone [Thu, 15 Aug 2013 00:10:24 +0000 (01:10 +0100)]
Add more missing config.h includes

config.h includes were missing in a few files, including input.c, the
lack of which caused the X11 backend to segfault instantly due to not
having an xkbcommon context.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
10 years agomalloc + memset -> zalloc
Peter Hutterer [Thu, 8 Aug 2013 01:57:05 +0000 (11:57 +1000)]
malloc + memset -> zalloc

And for clients using the xmalloc helper, use xzalloc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoudev: Use WL_OUTPUT udev attribute for pairing touchscreens to outputs
Kristian Høgsberg [Mon, 22 Jul 2013 22:11:11 +0000 (15:11 -0700)]
udev: Use WL_OUTPUT udev attribute for pairing touchscreens to outputs

10 years agocompositor-drm: Enable seat constraining when configured in weston.ini
Rob Bradford [Tue, 25 Jun 2013 17:56:42 +0000 (18:56 +0100)]
compositor-drm: Enable seat constraining when configured in weston.ini

This change tweaks weston_pointer_clamp to take into consideration if a
seat is constrained to a particular output by only considering the
pointer position valid if it is within the output we a constrained to.
This function is also used for the initial warping of the pointer when a
constraint is first established.

The other two changes are the application of the constraint when either
a new device added or a new output created and therefore outputs and
input devices can be brought up in either order.

v2: the code in create_output_for_connector has been spun off into a
new function setup_output_seat_constraint (Ander). The inappropriate
warping behaviour has been resolved by using weston_pointer_clamp
(Pekka).

10 years agoudev-seat: Refactor out seat lookup and possible creation
Rob Bradford [Tue, 25 Jun 2013 17:56:40 +0000 (18:56 +0100)]
udev-seat: Refactor out seat lookup and possible creation

This change spills the code for looking up a seat by name and then
potentially creating it if it doesn't exist into a new function called
udev_seat_get_named.

This change allows us to reuse this code when looking up the seat
when parsing seat constraints per output.

10 years agoconfigure.ac: Enable AC_USE_SYSTEM_EXTENSIONS
Daniel Stone [Wed, 22 May 2013 15:03:19 +0000 (18:03 +0300)]
configure.ac: Enable AC_USE_SYSTEM_EXTENSIONS

AC_USE_SYSTEM_EXTENSIONS enables _XOPEN_SOURCE, _GNU_SOURCE and similar
macros to expose the largest extent of functionality supported by the
underlying system.  This is required since these macros are often
limiting rather than merely additive, e.g. _XOPEN_SOURCE will actually
on some systems hide declarations which are not part of the X/Open spec.

Since this goes into config.h rather than the command line, ensure all
source is consistently including config.h before anything else,
including system libraries.  This doesn't need to be guarded by a
HAVE_CONFIG_H ifdef, which was only ever a hangover from the X.Org
modular transition.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
[pq: rebased and converted more files]

10 years agoudev-seat: Use udev rules to support multiple seats
Rob Bradford [Fri, 31 May 2013 17:09:59 +0000 (18:09 +0100)]
udev-seat: Use udev rules to support multiple seats

By labelling devices with ENV{WL_SEAT} in udev rules the devices will be
pulled into multiple weston seats.

As a result you can get multiple independent seats under the DRM and
fbdev backends.

10 years agoudev-seat: Separate the seat out to its own structure
Rob Bradford [Fri, 31 May 2013 17:09:58 +0000 (18:09 +0100)]
udev-seat: Separate the seat out to its own structure

Thie will allow us to instantiate multiple seats.

10 years agoudev-seat: Make the udev_input structure an embedded structure
Rob Bradford [Fri, 31 May 2013 17:09:55 +0000 (18:09 +0100)]
udev-seat: Make the udev_input structure an embedded structure

And as a result of this stop iterating through the compositor seat list
(of one item) and instead access the udev_input structure directly.

This enables a refactoring to pull out the weston_seat into a separate
structure permitting multiple seats.

10 years agoudev-seat: Rename udev_seat to udev_input
Rob Bradford [Fri, 31 May 2013 17:09:54 +0000 (18:09 +0100)]
udev-seat: Rename udev_seat to udev_input

This is a pure rename of the structure, functions and local variables in
preparation of the separation of the seat from the other udev input
handling.

10 years agoinput: Add a seat name parameter to weston_seat_init
Rob Bradford [Fri, 31 May 2013 17:09:50 +0000 (18:09 +0100)]
input: Add a seat name parameter to weston_seat_init

10 years agoudev-seat: Fail input setup only if no devices are found
Rob Bradford [Mon, 3 Jun 2013 17:46:13 +0000 (18:46 +0100)]
udev-seat: Fail input setup only if no devices are found

Rather than failing if we cannot open any single device fail the input
setup if there are no input devices added.

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

10 years agoinput: Merge wl_seat into weston_seat
Kristian Høgsberg [Tue, 7 May 2013 03:19:49 +0000 (23:19 -0400)]
input: Merge wl_seat into weston_seat

10 years agoudev-seat: Simplfy enable/disable interface a bit
Kristian Høgsberg [Mon, 18 Feb 2013 21:50:19 +0000 (16:50 -0500)]
udev-seat: Simplfy enable/disable interface a bit

We always call enable_udev_monitor and add_devices together and always
disable_udev_monitor and remove_devices together.  Let's just have one
entry point for enable and one for disable.

10 years agocompositor-drm: Move udev_seat to its own file
Kristian Høgsberg [Mon, 18 Feb 2013 21:15:53 +0000 (16:15 -0500)]
compositor-drm: Move udev_seat to its own file

We get to move the input code out of compositor-drm.c and we'll be
able to share it with the fbdev backend.

10 years agoDon't use the `seat' concept on device capability enum
Jonas Ådahl [Wed, 13 Nov 2013 21:11:34 +0000 (22:11 +0100)]
Don't use the `seat' concept on device capability enum

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoPort evdev code to be used as a shared library
Jonas Ådahl [Sun, 10 Nov 2013 16:55:40 +0000 (17:55 +0100)]
Port evdev code to be used as a shared library

This commit introduces build script configuration for building a shared
library 'libinput.so' containing the evdev input device functionality
from weston.

evdev.c, evdev.h and evdev-touchpad.c are ported to not use the data
structures and API in weston and libwayland-server in order to minimize
dependencies.

The API of filter.c and filter.h are renamed to not include the
'weston_' prefix.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agofilter: Remove unused variable
Jonas Ådahl [Tue, 12 Nov 2013 20:52:03 +0000 (21:52 +0100)]
filter: Remove unused variable

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevdev: Synchronize keys only if seat is keyboard capable
Jonas Ådahl [Sun, 10 Nov 2013 15:35:32 +0000 (16:35 +0100)]
evdev: Synchronize keys only if seat is keyboard capable

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoMake weston_output_transform_coordinate() take wl_fixed_t coordinates
Jonas Ådahl [Sat, 9 Nov 2013 23:30:10 +0000 (00:30 +0100)]
Make weston_output_transform_coordinate() take wl_fixed_t coordinates

This is to make it possible for future API to have non-integer
coordinates as input.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agocompositor: Remove redundant and not well-defined focus field
Kristian Høgsberg [Tue, 22 Oct 2013 19:40:54 +0000 (12:40 -0700)]
compositor: Remove redundant and not well-defined focus field

It was never clear what this field really did.

10 years agoevdev: Reference count input device's seat capabilities
Jonas Ådahl [Thu, 17 Oct 2013 21:04:05 +0000 (23:04 +0200)]
evdev: Reference count input device's seat capabilities

When the only input device of a certain seat capability is unplugged,
stop advertising the capability.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>