GNOME Bugzilla – Bug 774115
settings: Fix coordinate mapping of absolute devices
Last modified: 2017-02-10 16:27:08 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.
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.
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.
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.
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.
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.
Review of attachment 339342 [details] [review]: lgtm
Review of attachment 339343 [details] [review]: lgtm, I'm hoping you got the ratio calculation right, I didn't re-test that on paper :)
Review of attachment 339344 [details] [review]: lgtm
Review of attachment 339345 [details] [review]: lgtm
Review of attachment 339346 [details] [review]: lgtm
(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.
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