[PATCH weston 16/25] libweston: introduce notify_touch_cal() and doc

Pekka Paalanen ppaalanen at gmail.com
Mon Apr 23 10:51:32 UTC 2018


On Tue, 10 Apr 2018 12:37:15 +0300
Pekka Paalanen <ppaalanen at gmail.com> wrote:

> On Mon, 9 Apr 2018 12:12:49 +1000
> Peter Hutterer <peter.hutterer at who-t.net> wrote:
> 
> > On Fri, Mar 23, 2018 at 02:00:56PM +0200, Pekka Paalanen wrote:  
> > > From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> > > 
> > > notify_touch_cal() is an extended form of notify_touch(), adding
> > > normalized touch coordinates which are necessary for calibrating a
> > > touchscreen.
> > > 
> > > It would be possible to invert the transformation and convert from
> > > global coordinates to normalized device coordinates in input.c without
> > > adding this API, but this way it is more robust against code changes.
> > > 
> > > Recovering normalized device coordinates is necessary because libinput
> > > calibration matrix must be given in normalized units, and it would be
> > > difficult to compute otherwise. Libinput API does not offer normalized
> > > coordinates directly either, but those can be fetched by pretending the
> > > output resolution is 1x1.
> > > 
> > > Anticipating touch calibration mode, the old notify_touch() is renamed
> > > into a private process_touch_normal(), and the new notify_touch_cal()
> > > delegates to it.
> > > 
> > > Co-developed by Louis-Francis and Pekka.
> > > 
> > > Cc: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
> > > Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> > > ---
> > >  libweston/compositor.h      | 21 +++++++++++++++-
> > >  libweston/input.c           | 60 ++++++++++++++++++++++++++++++++++++---------
> > >  libweston/libinput-device.c | 11 ++++++++-
> > >  3 files changed, 79 insertions(+), 13 deletions(-)

> > Also, at this point I can only say creating structs for each coordinate type
> > in libinput has helped greatly in understanding what exactly you're dealing
> > with at any point in time. see libinput-private.h:
> > 
> > /* A coordinate pair in device coordinates */
> > struct device_coords {
> >         int x, y;
> > };
> > 
> > /* A dpi-normalized coordinate pair */
> > struct normalized_coords {
> >         double x, y;
> > };
> > 
> > /* A pair of coordinates normalized to a [0,1] or [-1, 1] range */
> > struct normalized_range_coords {
> >         double x, y;
> > };
> > 
> > 
> > etc. These are passed through the various functions, so the compiler will
> > tell you when you're passing a device coordinate into something that should
> > take a [0, 1] normalized range. I cannot recommend this enough when you're
> > dealing with more than one coordinate system.  
> 
> That's a good idea indeed. I think I'll re-spin with that.

On second thought, even adding just

struct weston_point_global_double {
	double x;
	double y;
};

would be touching quite many places, and it would prompt me to add

struct weston_point_global_fixed {
	wl_fixed_t x;
	wl_fixed_t y;
};

which would touch even more that I'd probably be touching almost all
APIs there are. Those would need to be complemented with struct
weston_point_surface_{double,fixed} as well.

So if you don't mind, I would leave that yak for another time.

But, maybe I can start with struct weston_2d_normalized_range_coords
since that's not used elsewhere at all. If I can figure out a bit
shorter name... weston_point2d_output_normalized...


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180423/0fde847a/attachment.sig>


More information about the wayland-devel mailing list