libweston: implement touch calibration protocol

This implements a new global interface weston_touch_calibration, which
allows one client at a time to perform touchscreen calibration. This
also implements the calibrator window management.

A client asks to calibrate a specific physical touch device (not a
wl_seat which may have several physical touch devices aggregated).
Libweston grabs all touch devices and prevents normal touch event
handling during the calibation sequence.

API is added to enable this new global interface, but it not yet called
by anything. Since the implementation allows clients to grab touch devices
arbitrarily, it is not enabled by default. The compositor should take
measures to prevent unexpected access to the interface.

A client may upload a new calibration to the compositor. There is a
vfunc to allow the compositor to reject/accept it and save it to
persistent storage. The persistent storage could be a udev rule
setting LIBINPUT_CALIBRATION_MATRIX, so that all display server would
load the new calibration automatically.

Co-developed by Louis-Francis and Pekka.

v2:
- use struct weston_point2d_device_normalized
- use syspath instead of devpath
- wrong_touch was renamed to invalid_touch
- rename weston_touch_calibrator::cancelled to calibration_cancelled
- send invalid_touch on out-of-bounds touch-down
- cancel touch sequence and send invalid_touch on motion going
  out-of-bounds
- rename calcoord_from_double() to wire_uint_from_double()
- send bad_coordinates error in touch_calibrator_convert()
- conversion results in 0,0 if cancelled

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
4 files changed