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

11 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>
11 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>
11 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>
11 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>
11 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>
11 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.

11 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>
11 years agoevdev: release devices on read() error
David Herrmann [Tue, 15 Oct 2013 12:29:56 +0000 (14:29 +0200)]
evdev: release devices on read() error

If read() fails without EAGAIN/EINTR, the device is very likely dead.
However, we must not remove the device as it might be muted/revoked. So we
simply remove the event-source to avoid polling the device and simply wait
for the udev-remove signal now.

Note that we cannot call evdev_device_destroy() as the caller created the
FD and might need custom code to close it (like weston_launcher_close()).

11 years agoevdev: Clear touch capability if we see a mouse-type button
Kristian Høgsberg [Mon, 14 Oct 2013 22:46:13 +0000 (15:46 -0700)]
evdev: Clear touch capability if we see a mouse-type button

If an input device has BTN_LEFT (typically) it's not a touch screen but
a touch pad.

11 years agoevdev: Only init a pointer if the evdev device has a button
Kristian Høgsberg [Mon, 14 Oct 2013 22:32:08 +0000 (15:32 -0700)]
evdev: Only init a pointer if the evdev device has a button

We used to test for abs | rel | button,  which inits a pointer device for
a device with just rel or abs capabilities.  We now make sure we have either
rel or abs as well as button.

11 years agoevdev: Stop looking for pointer buttons when we get to BTN_JOYSTICK
Kristian Høgsberg [Mon, 14 Oct 2013 22:28:01 +0000 (15:28 -0700)]
evdev: Stop looking for pointer buttons when we get to BTN_JOYSTICK

We don't want to mark a touchscreen as a button device just because it
exposes the BTN_TOUCH and BTN_TOOL buttons.

11 years agoevdev: Process touch up events of single-touch devices
Neil Roberts [Tue, 24 Sep 2013 19:05:07 +0000 (20:05 +0100)]
evdev: Process touch up events of single-touch devices

Previously only the touch up key event was used for single-touch
devices and the touch down event was generated on the first motion
event. This was breaking if the touch up and down events were sent
without a motion in-between because the evdev driver wouldn't generate
a touch down event and Weston would lose track of the number of touch
points that are down. This patch changes it to track the up and down
key events as pending events similar to how it does for multi-touch
devices.

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

11 years agoevdev: Only track one pending event
Neil Roberts [Tue, 24 Sep 2013 11:09:03 +0000 (12:09 +0100)]
evdev: Only track one pending event

Instead of having a mask of pending events there is now an enum with a
single value to represent the one pending event. The event gets
flushed explicitly as part of the handling code for each event type
rather than in the outer event reading loop. The pending event is used
so that we can combine multiple motion events into one and to make
sure that we have recieved the latest position before sending a touch
up or down event. This should fix the following problems with the old
approach:

• If you release a finger and press it down again quickly you could
  get the up and down events in the same batch. However the pending
  events were always processed in the order down then up so it would
  end up notifying two down events and then an up. The pending event
  is now always flushed when there is a new up or down event so they
  will always be in the right order.

• When it got a slot event it would immediately change the slot number
  and then set the pending event. Then when it flushed the events it
  would use the new slot number to flush the old pending event so the
  events could have the wrong finger. The pending event is now
  immediately flushed when a slot event is received so it will have
  the right finger.

• If you get more than 32 events in one read then it was resetting the
  pending events before processing the next batch in
  evdev_process_events. If four fingers were pressed down at once then
  it ended up with more than 32 events and the sync message would be
  in the second batch. The pending flag for the last finger was
  getting cleared so it never got emitted. In this patch the pending
  event is no longer reset after reading nor is it explicitly flushed.
  Instead it is flushed when we receive a EV_SYN event or a different
  pending event needs to replace it.

The touchpad handling code was trying to use the pending event
mechanism to notify the relative motion events. I'm not sure why it
was doing this because it looks the event would effectively get
emitted as soon as the touchpad_process function is finished anyway
and it wasn't accumulating the values. Instead I've just changed it to
emit the event directly.

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

11 years agoevdev: Flush motion events when the slot changes, not just after sync
Neil Roberts [Fri, 20 Sep 2013 14:03:29 +0000 (15:03 +0100)]
evdev: Flush motion events when the slot changes, not just after sync

If two fingers are released almost simultaneously then evdev can send
the touch up events in one bunch without sending a sync event
in-between. However, the evdev_device struct only keeps track of one
pending touch up event so in this case the second touch up event would
override the first and it would be lost. This patch changes it to also
flush the events whenever the slot changes so that it will flush the
previous touch up event before trying to queue the next one.

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

11 years agoRename current, origin, scale, origin_scale
Hardening [Wed, 18 Sep 2013 21:56:35 +0000 (23:56 +0200)]
Rename current, origin, scale, origin_scale

This patch renames that fields to have consistent names.

11 years agoevdev: Don't parse config file again, use compositor->config
Kristian Høgsberg [Thu, 29 Aug 2013 20:49:35 +0000 (13:49 -0700)]
evdev: Don't parse config file again, use compositor->config

11 years agoevdev: Don't transform device->abs.x/y in place
Kristian Høgsberg [Thu, 29 Aug 2013 05:12:24 +0000 (22:12 -0700)]
evdev: Don't transform device->abs.x/y in place

We don't always get both an X and an Y event in a SYN report, so we end
up transforming the coordinate we don't get twice.  For example, if we
only receive an ABS_X event, we transform the already transformed
device->abs.y again in transform_absolute() when applying the calibration.

11 years agoevdev: Initliaze device->link so we can wl_list_remove() without crashing
Kristian Høgsberg [Mon, 26 Aug 2013 21:35:32 +0000 (14:35 -0700)]
evdev: Initliaze device->link so we can wl_list_remove() without crashing

We were testing for wl_list_empty() on a { NULL, NULL } list (which
returns false) and then wl_list_remove()ing the device (which crashes).

11 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>
11 years agoevdev: Ignore joystick devices
Kristian Høgsberg [Tue, 13 Aug 2013 21:55:39 +0000 (14:55 -0700)]
evdev: Ignore joystick devices

We don't handle them in any way now and having your steering wheel move
the cursor isn't useful.  Applications can still open evdev devices and
access them directly like they already do.

11 years agoevdev-touchpad: Set some options using weston.ini
Armin K [Tue, 30 Jul 2013 23:41:03 +0000 (01:41 +0200)]
evdev-touchpad: Set some options using weston.ini

This patch adds 3 new options to weston.ini to allow
the user to change default constant_accel_factor,
min_accel_factor and max_accel_factor. If no options
are set, it falls back using defaults as it did before.

v2: create weston_config_section_get_double and use it
instead of manualy converting string to double.

v3: add default values in weston_config_get_double
instead of using conditionals.

v4: don't pass diagonal as pointer.

11 years agoevdev: write EV_SYN input_event along with led events to device
Rolf Morel [Fri, 9 Aug 2013 14:32:17 +0000 (16:32 +0200)]
evdev: write EV_SYN input_event along with led events to device

Other clients of an evdev device need to have the events they receive
be separated, in moment in time, from other events by an EV_SYN/
SYN_REPORT. This is the responsibility of the client who writes events
into the stream.

11 years agoevdev: Use touch ID 0 when generating touch up event
Rusty Lynch [Fri, 9 Aug 2013 04:08:17 +0000 (21:08 -0700)]
evdev: Use touch ID 0 when generating touch up event

device->mt.slot is uninitialized when we're not receiving the
evdev slot events.  Always use ID 0 as we do when we generate the
touch down and motion events.

11 years agoevdev: log when a device is used as touchpad
Peter Hutterer [Wed, 7 Aug 2013 01:04:49 +0000 (11:04 +1000)]
evdev: log when a device is used as touchpad

11 years agoevdev: call evdev_device_destroy on failure
Peter Hutterer [Wed, 7 Aug 2013 01:04:48 +0000 (11:04 +1000)]
evdev: call evdev_device_destroy on failure

Avoid keeping keeping what needs to be freed in sync in multiple places,
make evdev_device_destroy do the right thing instead.

11 years agoevdev: plug a potential memleak
Peter Hutterer [Wed, 7 Aug 2013 01:04:47 +0000 (11:04 +1000)]
evdev: plug a potential memleak

For touchpads, device->dispatch is set up when exiting
evdev_handle_device() and a potential source for a memleak.
This can't actually happen at the moment, as evdev_handle_device() won't
fail for touchpads after setting up the dispatch but prevent this from
happening in the future.

11 years agoevdev: get the current slot value from the absinfo struct or mtdev
Peter Hutterer [Wed, 7 Aug 2013 01:04:46 +0000 (11:04 +1000)]
evdev: get the current slot value from the absinfo struct or mtdev

If touches are already present on the device, absinfo has the currently
active touch slot. There's a race condition where the slot may change before
we enable the fd and we thus miss out on the ABS_MT_SLOT event. It's still
slightly more correct than assuming whatever comes next is slot 0.

11 years agoevdev: only use mtdev for Protocol A devices
Peter Hutterer [Wed, 7 Aug 2013 01:04:45 +0000 (11:04 +1000)]
evdev: only use mtdev for Protocol A devices

For Protocol B devices, mtdev merely routes the events and is not needed.
For Protocol A devices, mtdev is needed, so fail for those devices now if we
mtdev fails.

11 years agoevdev: add comment why we're ignoring key value 2
Peter Hutterer [Wed, 7 Aug 2013 01:04:42 +0000 (11:04 +1000)]
evdev: add comment why we're ignoring key value 2

11 years agoevdev: prevent unterminated device name
Peter Hutterer [Wed, 7 Aug 2013 01:04:41 +0000 (11:04 +1000)]
evdev: prevent unterminated device name

The kernel copies up to sizeof(devname) bytes but doesn't null-terminate the
string if the device name exceeds the size of the supplied buffer.

11 years agoevdev: check for ABS_MT_POSITION_X/Y to determine mt devices
Peter Hutterer [Thu, 8 Aug 2013 02:03:08 +0000 (12:03 +1000)]
evdev: check for ABS_MT_POSITION_X/Y to determine mt devices

mtdev as currently used in weston is a noop. mtdev's purpose is to convert
Protocol A devices (without ABS_MT_SLOT) to Protocol B devices (slots).
For Protocol B devices mtdev merely routes the events, so checking for
slots and then using mtdev based on that adds no functionality.

Check for ABS_MT_POSITION_X/Y instead and use that to categorise a device
as MT device. mtdev will provide us with a slotted protocol for all devices.

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

11 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>
11 years agoevdev: Suport old-style single-touch touch screens
Kristian Høgsberg [Fri, 26 Jul 2013 17:43:26 +0000 (10:43 -0700)]
evdev: Suport old-style single-touch touch screens

These screens send only BTN_TOUCH and ABS_X/Y.

11 years agoevdev: Use temporary x and y coordinates when applying calibration
Kristian Høgsberg [Fri, 26 Jul 2013 17:41:43 +0000 (10:41 -0700)]
evdev: Use temporary x and y coordinates when applying calibration

Don't overwrite device->abs.x halfway through the matrix multiplication.

11 years agoevdev: Don't add output offset in evdev_process_absolute_motion()
Kristian Høgsberg [Fri, 26 Jul 2013 17:40:32 +0000 (10:40 -0700)]
evdev: Don't add output offset in evdev_process_absolute_motion()

We do that in weston_output_transform_coordinate() now.

11 years agoevdev: Use weston_output_transform_coordinate for evdev touch screens
Kristian Høgsberg [Mon, 22 Jul 2013 22:09:30 +0000 (15:09 -0700)]
evdev: Use weston_output_transform_coordinate for evdev touch screens

11 years agotouchpad: Handle two-finger click as right click for button pads
Kristian Høgsberg [Mon, 1 Jul 2013 16:48:55 +0000 (12:48 -0400)]
touchpad: Handle two-finger click as right click for button pads

11 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]

11 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

11 years agoevdev-touchpad: Disable tap FSM by default on touchpads with button pads
Jonas Ådahl [Fri, 22 Mar 2013 07:41:42 +0000 (08:41 +0100)]
evdev-touchpad: Disable tap FSM by default on touchpads with button pads

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agocompositor: Support notifying with absolute position too
Rob Bradford [Wed, 27 Mar 2013 15:59:43 +0000 (15:59 +0000)]
compositor: Support notifying with absolute position too

With evdev input devices that generate absolute positions we need to provide
an infrastructure in the compositor for supporting those.

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

11 years agocompositor: Change notify_motion to take relative motion events
Kristian Høgsberg [Mon, 25 Feb 2013 22:04:47 +0000 (17:04 -0500)]
compositor: Change notify_motion to take relative motion events

11 years agoevdev: Wait for SYN event before sending events over to the client
Satyeshwar Singh [Wed, 27 Feb 2013 20:26:23 +0000 (15:26 -0500)]
evdev: Wait for SYN event before sending events over to the client

The issue was that touch::down event from the compositor to client apps
would send the previous motion events coordinates and this obviously made
the client do the wrong thing. This happened because we were not waiting
for a SYN event to come from evdev before sending down, motion or up events.

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

11 years agoxkb: Don't call exit on failure in weston_compositor_xkb_init()
Kristian Høgsberg [Sat, 16 Feb 2013 19:29:24 +0000 (14:29 -0500)]
xkb: Don't call exit on failure in weston_compositor_xkb_init()

This will exit without cleaning vt modes and leave the system stuck.

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

11 years agoevdev: Apply calibration values to absolute events
Rob Bradford [Mon, 3 Dec 2012 19:44:16 +0000 (19:44 +0000)]
evdev: Apply calibration values to absolute events

Store a set of calibration values per device - these calibration values are
just applied to the absolute motion events.

11 years agoevdev: Include the device capabilities in the debugging
Rob Bradford [Mon, 3 Dec 2012 19:44:13 +0000 (19:44 +0000)]
evdev: Include the device capabilities in the debugging

11 years agoFix a typo.
Dima Ryazanov [Sun, 11 Nov 2012 08:29:01 +0000 (00:29 -0800)]
Fix a typo.

11 years agoevdev: Update axis notifications to follow protocol
Jonas Ådahl [Wed, 3 Oct 2012 20:56:58 +0000 (22:56 +0200)]
evdev: Update axis notifications to follow protocol

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agoevdev-touchpad: Implement two finger scroll
Jonas Ådahl [Thu, 27 Sep 2012 16:40:43 +0000 (18:40 +0200)]
evdev-touchpad: Implement two finger scroll

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agoevdev-touchpad: Add a finite-state machine
Jonas Ådahl [Thu, 27 Sep 2012 16:40:40 +0000 (18:40 +0200)]
evdev-touchpad: Add a finite-state machine

The finite-state machine is so far used to implement support for tapping
and dragging.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agoevdev-touchpad: Cleanup and refactoring
Jonas Ådahl [Thu, 27 Sep 2012 16:40:39 +0000 (18:40 +0200)]
evdev-touchpad: Cleanup and refactoring

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agoevdev-touchpad: Iterate over the touchpad spec table correctly
Rob Bradford [Tue, 9 Oct 2012 17:44:32 +0000 (18:44 +0100)]
evdev-touchpad: Iterate over the touchpad spec table correctly

The original code would overrun since the calculation of the range did not
take into consideration the size of the entries in the table.

Cc:Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Rob Bradford <rob@linux.intel.com>
11 years agoevdev: Avoid unintended case drop through
Rob Bradford [Tue, 9 Oct 2012 17:44:31 +0000 (18:44 +0100)]
evdev: Avoid unintended case drop through

e->code is in the same range for ABS_ and for REL_. As the code currently
stands and for the current values in Linux's input.h there is no risk of a
problem. However just in case it would be wise to break after evaluating the
relative events.

Signed-off-by: Rob Bradford <rob@linux.intel.com>
11 years agoevdev-touchpad: Twiddle finger_state correctly
Rob Bradford [Tue, 9 Oct 2012 17:44:29 +0000 (18:44 +0100)]
evdev-touchpad: Twiddle finger_state correctly

The original code always set the finger_state to the appropriate bitmask
irrespective of whether the event was a press or a release. It would also blat
all members of the bitmask rather than ORing in the new bit for the event.

Cc:Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Rob Bradford <rob@linux.intel.com>
11 years agocompositor: Change notify_* function to take a weston_seat
Kristian Høgsberg [Fri, 10 Aug 2012 13:50:11 +0000 (09:50 -0400)]
compositor: Change notify_* function to take a weston_seat

Fewer indirections and derefs, and it's also more appropriate for a
backend calling into weston core to pass a weston_seat.

11 years agoevdev: rename evdev_input_device to evdev_device
Pekka Paalanen [Mon, 6 Aug 2012 11:57:08 +0000 (14:57 +0300)]
evdev: rename evdev_input_device to evdev_device

As said by krh: "Maybe we should also just call it an evdev_device
instead, shorter [and] not really ambiguous."

[krh: if my typo filled irc is going in a commit message, I'm at least going
to insert the missing words.]

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoevdev: do not pass a list to evdev_led_update()
Pekka Paalanen [Mon, 6 Aug 2012 11:57:07 +0000 (14:57 +0300)]
evdev: do not pass a list to evdev_led_update()

evdev_led_update() does not really need the whole list of device at
once, it can be called one device at a time.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoevdev: kill a warning in evdev_led_update()
Pekka Paalanen [Fri, 3 Aug 2012 11:39:14 +0000 (14:39 +0300)]
evdev: kill a warning in evdev_led_update()

evdev.c: In function 'evdev_led_update':
evdev.c:57:9: warning: ignoring return value of 'write', declared with
attribute warn_unused_result

Useless in this case.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agocompositor-drm, evdev: don't crash on missing keyboard
Pekka Paalanen [Fri, 3 Aug 2012 11:39:11 +0000 (14:39 +0300)]
compositor-drm, evdev: don't crash on missing keyboard

Weston's notify_keyboard_focus_*() assume that a keyboard is present, if
they are called. With evdev, there might not always be a keyboard.

Also clean up the variable definition in evdev_notify_keyborad_focus().
I read that function through many times and finally had to grep where
does 'all_keys' come from.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoevdev: log input devices
Pekka Paalanen [Fri, 3 Aug 2012 11:39:07 +0000 (14:39 +0300)]
evdev: log input devices

Write information about found input devices into the log. Also fetch and
record the device name.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoevdev: move udev code into compositor-drm.c
Pekka Paalanen [Fri, 3 Aug 2012 17:30:30 +0000 (13:30 -0400)]
evdev: move udev code into compositor-drm.c

Move all udev-related and now drm backend specific code into
compositor-drm.c.

This makes evdev.c free of udev and launcher-util, and allows it to be
used on Android.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoevdev: expose the generic evdev API
Pekka Paalanen [Fri, 3 Aug 2012 11:39:05 +0000 (14:39 +0300)]
evdev: expose the generic evdev API

This API does not depend on udev or launcher-util.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoevdev: rename evdev_seat to drm_seat
Pekka Paalanen [Fri, 3 Aug 2012 11:39:04 +0000 (14:39 +0300)]
evdev: rename evdev_seat to drm_seat

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoevdev: pass weston_seat to evdev_input_device_create()
Pekka Paalanen [Fri, 3 Aug 2012 11:39:03 +0000 (14:39 +0300)]
evdev: pass weston_seat to evdev_input_device_create()

in preparation of removing evdev_seat

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoevdev: make evdev_notify_keyboard_focus() independent of evdev_seat
Pekka Paalanen [Fri, 3 Aug 2012 11:39:02 +0000 (14:39 +0300)]
evdev: make evdev_notify_keyboard_focus() independent of evdev_seat

in preparation of removing evdev_seat

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoevdev: make evdev_led_update independent from struct evdev_seat
Pekka Paalanen [Fri, 3 Aug 2012 11:39:01 +0000 (14:39 +0300)]
evdev: make evdev_led_update independent from struct evdev_seat

in preparation of removing evdev_seat

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoevdev: change evdev_seat into weston_seat in struct evdev_input_device
Pekka Paalanen [Fri, 3 Aug 2012 11:39:00 +0000 (14:39 +0300)]
evdev: change evdev_seat into weston_seat in struct evdev_input_device

We are phasing out struct evdev_seat.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>