Re: [PATCH weston 12/25] input: introduce weston_touch_device

2018-04-10 Thread Pekka Paalanen
On Mon, 9 Apr 2018 11:55:51 +1000
Peter Hutterer  wrote:

> On Fri, Mar 23, 2018 at 02:00:52PM +0200, Pekka Paalanen wrote:
> > From: Louis-Francis Ratté-Boulianne 
> > 
> > Introduce weston_touch_device for libweston core to track individual
> > touchscreen input devices. A weston_seat/weston_touch may be an
> > aggregation of several physical touchscreen input devices. Separating
> > the physical devices will be required for implementing touchscreen
> > calibration. One can only calibrate one device at a time, and we want to
> > make sure to handle the right one.
> > 
> > Both backends that support touch devices are updated to create
> > weston_touch_devices. Wayland-backend provides touch devices that cannot
> > be calibrated, because we have no access to raw touch coordinates from
> > the device - calibration is the responsibility of the parent display
> > server. Libinput backend provides touch devices that can be calibrated,
> > hence implementing the set and get calibration hooks.
> > 
> > Backends need to maintain an output pointer in any case, so we have a
> > get_output() hook instead of having to maintain an identical field in
> > weston_touch_device. The same justification applies to
> > get_calibration_head_name.
> > 
> > Also update the test plugin to manage weston_touch_device objects.
> > 
> > Co-developed by Louis-Francis and Pekka.  
> 
> just a little nit: you're going to make the world an every so slightly
> angrier place by choosing "calb" instead of "calib" or "cal" as shortcut for
> "calibration" :)
> 
> I predict that almost everyone working on that code will mistype that the
> first few times around.

Right, I can try to think of another name for the calibration matrix
local variable.


Thanks,
pq


pgpaBCli1X83x.pgp
Description: OpenPGP digital signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 12/25] input: introduce weston_touch_device

2018-04-08 Thread Peter Hutterer
On Fri, Mar 23, 2018 at 02:00:52PM +0200, Pekka Paalanen wrote:
> From: Louis-Francis Ratté-Boulianne 
> 
> Introduce weston_touch_device for libweston core to track individual
> touchscreen input devices. A weston_seat/weston_touch may be an
> aggregation of several physical touchscreen input devices. Separating
> the physical devices will be required for implementing touchscreen
> calibration. One can only calibrate one device at a time, and we want to
> make sure to handle the right one.
> 
> Both backends that support touch devices are updated to create
> weston_touch_devices. Wayland-backend provides touch devices that cannot
> be calibrated, because we have no access to raw touch coordinates from
> the device - calibration is the responsibility of the parent display
> server. Libinput backend provides touch devices that can be calibrated,
> hence implementing the set and get calibration hooks.
> 
> Backends need to maintain an output pointer in any case, so we have a
> get_output() hook instead of having to maintain an identical field in
> weston_touch_device. The same justification applies to
> get_calibration_head_name.
> 
> Also update the test plugin to manage weston_touch_device objects.
> 
> Co-developed by Louis-Francis and Pekka.

just a little nit: you're going to make the world an every so slightly
angrier place by choosing "calb" instead of "calib" or "cal" as shortcut for
"calibration" :)

I predict that almost everyone working on that code will mistype that the
first few times around.

Cheers,
   Peter

> 
> Signed-off-by: Louis-Francis Ratté-Boulianne 
> Signed-off-by: Pekka Paalanen 
> ---
>  libweston/compositor-wayland.c |  21 
>  libweston/compositor.h |  56 
>  libweston/input.c  |  65 +++
>  libweston/libinput-device.c| 116 
> -
>  libweston/libinput-device.h|   3 ++
>  tests/weston-test.c|  38 ++
>  6 files changed, 298 insertions(+), 1 deletion(-)
> 
> diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
> index f186681c..9d5b3551 100644
> --- a/libweston/compositor-wayland.c
> +++ b/libweston/compositor-wayland.c
> @@ -198,6 +198,8 @@ struct wayland_input {
>   } cursor;
>   } parent;
>  
> + struct weston_touch_device *touch_device;
> +
>   enum weston_key_state_update keyboard_state_update;
>   uint32_t key_serial;
>   uint32_t enter_serial;
> @@ -2246,6 +2248,22 @@ static const struct wl_touch_listener touch_listener = 
> {
>  };
>  
>  
> +static struct weston_touch_device *
> +create_touch_device(struct wayland_input *input)
> +{
> + struct weston_touch_device *touch_device;
> + char str[128];
> +
> + /* manufacture a unique'ish name */
> + snprintf(str, sizeof str, "wayland-touch[%u]",
> +  wl_proxy_get_id((struct wl_proxy *)input->parent.seat));
> +
> + touch_device = weston_touch_create_touch_device(input->base.touch_state,
> + str, NULL, NULL);
> +
> + return touch_device;
> +}
> +
>  static void
>  input_handle_capabilities(void *data, struct wl_seat *seat,
> enum wl_seat_capability caps)
> @@ -2287,7 +2305,10 @@ input_handle_capabilities(void *data, struct wl_seat 
> *seat,
>   wl_touch_add_listener(input->parent.touch,
> _listener, input);
>   weston_seat_init_touch(>base);
> + input->touch_device = create_touch_device(input);
>   } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->parent.touch) {
> + weston_touch_device_destroy(input->touch_device);
> + input->touch_device = NULL;
>   if (input->seat_version >= WL_TOUCH_RELEASE_SINCE_VERSION)
>   wl_touch_release(input->parent.touch);
>   else
> diff --git a/libweston/compositor.h b/libweston/compositor.h
> index 675ee68f..b08031ac 100644
> --- a/libweston/compositor.h
> +++ b/libweston/compositor.h
> @@ -453,10 +453,54 @@ struct weston_pointer {
>   struct wl_list timestamps_list;
>  };
>  
> +/** libinput style calibration matrix
> + *
> + * See https://wayland.freedesktop.org/libinput/doc/latest/absolute_axes.html
> + * and libinput_device_config_calibration_set_matrix().
> + */
> +struct weston_touch_device_matrix {
> + float m[6];
> +};
> +
> +struct weston_touch_device;
> +
> +/** Operations for a calibratable touchscreen */
> +struct weston_touch_device_ops {
> + /** Get the associated output if existing. */
> + struct weston_output *(*get_output)(struct weston_touch_device *device);
> +
> + /** Get the name of the associated head if existing. */
> + const char *
> + (*get_calibration_head_name)(struct weston_touch_device *device);
> +
> + /** Retrieve the 

[PATCH weston 12/25] input: introduce weston_touch_device

2018-03-23 Thread Pekka Paalanen
From: Louis-Francis Ratté-Boulianne 

Introduce weston_touch_device for libweston core to track individual
touchscreen input devices. A weston_seat/weston_touch may be an
aggregation of several physical touchscreen input devices. Separating
the physical devices will be required for implementing touchscreen
calibration. One can only calibrate one device at a time, and we want to
make sure to handle the right one.

Both backends that support touch devices are updated to create
weston_touch_devices. Wayland-backend provides touch devices that cannot
be calibrated, because we have no access to raw touch coordinates from
the device - calibration is the responsibility of the parent display
server. Libinput backend provides touch devices that can be calibrated,
hence implementing the set and get calibration hooks.

Backends need to maintain an output pointer in any case, so we have a
get_output() hook instead of having to maintain an identical field in
weston_touch_device. The same justification applies to
get_calibration_head_name.

Also update the test plugin to manage weston_touch_device objects.

Co-developed by Louis-Francis and Pekka.

Signed-off-by: Louis-Francis Ratté-Boulianne 
Signed-off-by: Pekka Paalanen 
---
 libweston/compositor-wayland.c |  21 
 libweston/compositor.h |  56 
 libweston/input.c  |  65 +++
 libweston/libinput-device.c| 116 -
 libweston/libinput-device.h|   3 ++
 tests/weston-test.c|  38 ++
 6 files changed, 298 insertions(+), 1 deletion(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index f186681c..9d5b3551 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -198,6 +198,8 @@ struct wayland_input {
} cursor;
} parent;
 
+   struct weston_touch_device *touch_device;
+
enum weston_key_state_update keyboard_state_update;
uint32_t key_serial;
uint32_t enter_serial;
@@ -2246,6 +2248,22 @@ static const struct wl_touch_listener touch_listener = {
 };
 
 
+static struct weston_touch_device *
+create_touch_device(struct wayland_input *input)
+{
+   struct weston_touch_device *touch_device;
+   char str[128];
+
+   /* manufacture a unique'ish name */
+   snprintf(str, sizeof str, "wayland-touch[%u]",
+wl_proxy_get_id((struct wl_proxy *)input->parent.seat));
+
+   touch_device = weston_touch_create_touch_device(input->base.touch_state,
+   str, NULL, NULL);
+
+   return touch_device;
+}
+
 static void
 input_handle_capabilities(void *data, struct wl_seat *seat,
  enum wl_seat_capability caps)
@@ -2287,7 +2305,10 @@ input_handle_capabilities(void *data, struct wl_seat 
*seat,
wl_touch_add_listener(input->parent.touch,
  _listener, input);
weston_seat_init_touch(>base);
+   input->touch_device = create_touch_device(input);
} else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->parent.touch) {
+   weston_touch_device_destroy(input->touch_device);
+   input->touch_device = NULL;
if (input->seat_version >= WL_TOUCH_RELEASE_SINCE_VERSION)
wl_touch_release(input->parent.touch);
else
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 675ee68f..b08031ac 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -453,10 +453,54 @@ struct weston_pointer {
struct wl_list timestamps_list;
 };
 
+/** libinput style calibration matrix
+ *
+ * See https://wayland.freedesktop.org/libinput/doc/latest/absolute_axes.html
+ * and libinput_device_config_calibration_set_matrix().
+ */
+struct weston_touch_device_matrix {
+   float m[6];
+};
+
+struct weston_touch_device;
+
+/** Operations for a calibratable touchscreen */
+struct weston_touch_device_ops {
+   /** Get the associated output if existing. */
+   struct weston_output *(*get_output)(struct weston_touch_device *device);
+
+   /** Get the name of the associated head if existing. */
+   const char *
+   (*get_calibration_head_name)(struct weston_touch_device *device);
+
+   /** Retrieve the current calibration matrix. */
+   void (*get_calibration)(struct weston_touch_device *device,
+   struct weston_touch_device_matrix *matrix);
+
+   /** Set a new calibration matrix. */
+   void (*set_calibration)(struct weston_touch_device *device,
+   const struct weston_touch_device_matrix 
*matrix);
+};
+
+/** Represents a physical touchscreen input device */
+struct weston_touch_device {
+   char *devpath;  /**< unique