After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 774115 - settings: Fix coordinate mapping of absolute devices
settings: Fix coordinate mapping of absolute devices
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: wayland
unspecified
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2016-11-08 17:46 UTC by Carlos Garnacho
Modified: 2017-02-10 16:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
clutter/evdev: Add ClutterInputDeviceEvdev::device-matrix property (7.33 KB, patch)
2016-11-08 17:47 UTC, Carlos Garnacho
committed Details | Review
clutter/evdev: Add ClutterInputDeviceEvdev::output-aspect-ratio (4.98 KB, patch)
2016-11-08 17:47 UTC, Carlos Garnacho
committed Details | Review
backends/native: Use ClutterInputDeviceEvdev::device-matrix for map-to-output (1.57 KB, patch)
2016-11-08 17:47 UTC, Carlos Garnacho
committed Details | Review
backends/native: Use libinput calibration matrix for calibration (1.59 KB, patch)
2016-11-08 17:47 UTC, Carlos Garnacho
committed Details | Review
backends/native: Implement keep-aspect (2.18 KB, patch)
2016-11-08 17:47 UTC, Carlos Garnacho
committed Details | Review

Description Carlos Garnacho 2016-11-08 17:46:51 UTC
Right now, when mapping abs devices (touchscreens/tablets), we're using libinput_device_config_calibration_set_matrix(), which is reportedly the wrong thing to do.

This function should just be used for calibration purposes in display-attached devices, It should be the compositor which maps the input device coordinates to the right area, on the post-calibration coordinates.

Rationale: a calibrated device might have "dead" areas on either side of the screen, if output mapping is put together with calibration, those dead areas are not dead, but actually make the pointer able to move outside the monitor area.

Rationale 2: to libinput only "direct" devices (as per INPUT_PROP_DIRECT) are calibratable, which certainly many tablets aren't. This made output mapping ignored on such devices.

I'm attaching some patches that add ClutterInputDevice::device-matrix and ::output-aspect-ratio properties, which allow us to use the calibration matrix for its right purpose, and coincidentally help me kill the last 2 FIXMEs in tablet configuration code.
Comment 1 Carlos Garnacho 2016-11-08 17:47:34 UTC
Created attachment 339342 [details] [review]
clutter/evdev: Add ClutterInputDeviceEvdev::device-matrix property

And transform absolute events using this matrix. This property is
akin to the "Coordinate Transformation Matrix" property in X11,
and will be used to map tablets/touchscreens to outputs, favoured
over the libinput matrix which is meant for calibration.
Comment 2 Carlos Garnacho 2016-11-08 17:47:40 UTC
Created attachment 339343 [details] [review]
clutter/evdev: Add ClutterInputDeviceEvdev::output-aspect-ratio

When != 0, this property will express the W:H ratio of the desired
output area (be it one monitor or the span of all monitors). At
the time of translating coordinates, coordinates will be skewed so
that the input area of the tablet is a rectangle of the given ratio.

Events happening in the input areas that fall outside the output
aspect ratio will be clamped to the nearest coordinate in the rect.

If the ratio is 0, the whole input area of the tablet will be used
and no coordinate skewing will happen.
Comment 3 Carlos Garnacho 2016-11-08 17:47:46 UTC
Created attachment 339344 [details] [review]
backends/native: Use ClutterInputDeviceEvdev::device-matrix for map-to-output

The libinput calibration matrix should only be used for calibration purposes,
this ClutterInputDeviceEvdev property has been added in place.
Comment 4 Carlos Garnacho 2016-11-08 17:47:52 UTC
Created attachment 339345 [details] [review]
backends/native: Use libinput calibration matrix for calibration

We couldn't properly merge output-mapping matrix and calibration into
one. Now that libinput calibration matrix is free to use, we can
actually implement tablet calibration with it.
Comment 5 Carlos Garnacho 2016-11-08 17:47:57 UTC
Created attachment 339346 [details] [review]
backends/native: Implement keep-aspect

Using ClutterInputDeviceEvdev::output-aspect-ratio. This only applies
to devices which are not calibratable, so again we need to implement
this at the toolkit level.
Comment 6 Peter Hutterer 2017-02-09 01:39:44 UTC
Review of attachment 339342 [details] [review]:

lgtm
Comment 7 Peter Hutterer 2017-02-09 01:42:22 UTC
Review of attachment 339343 [details] [review]:

lgtm, I'm hoping you got the ratio calculation right, I didn't re-test that on paper :)
Comment 8 Peter Hutterer 2017-02-09 01:42:50 UTC
Review of attachment 339344 [details] [review]:

lgtm
Comment 9 Peter Hutterer 2017-02-09 01:43:31 UTC
Review of attachment 339345 [details] [review]:

lgtm
Comment 10 Peter Hutterer 2017-02-09 01:56:56 UTC
Review of attachment 339346 [details] [review]:

lgtm
Comment 11 Carlos Garnacho 2017-02-10 16:23:57 UTC
(In reply to Peter Hutterer from comment #7)
> Review of attachment 339343 [details] [review] [review]:
> 
> lgtm, I'm hoping you got the ratio calculation right, I didn't re-test that
> on paper :)

I fwiw got it wrong :). if ratio<1 we want to stretch the Y axis by the inverse, we are otherwise shrinking it.

I'm pushing the patchset with this fix and some changes to actually clamp the coordinates to the mapped monitor instead of letting them spill outside.
Comment 12 Carlos Garnacho 2017-02-10 16:26:29 UTC
Attachment 339342 [details] pushed as cc838ea - clutter/evdev: Add ClutterInputDeviceEvdev::device-matrix property
Attachment 339343 [details] pushed as 1ff9bbd - clutter/evdev: Add ClutterInputDeviceEvdev::output-aspect-ratio
Attachment 339344 [details] pushed as dae5f06 - backends/native: Use ClutterInputDeviceEvdev::device-matrix for map-to-output
Attachment 339345 [details] pushed as cfbc4fe - backends/native: Use libinput calibration matrix for calibration
Attachment 339346 [details] pushed as 45c9786 - backends/native: Implement keep-aspect