[libinput] Find screen for touch screen devices and calibrate accordingly
ClosedPublic

Authored by graesslin on Nov 10 2017, 5:14 PM.

Details

Summary

This change finds the screen for a touch screen device based on:

  • number available screens
  • output name defined on the touch screen device
  • internal screen
  • and physical size

The id of the screen is stored in the Device allowing to adjust the
touch points accordingly. This means instead of transferring to the
combined display size the touch points are transferred into the output
space and the position of the output is added. Thus in a multi screen
system the touch points are properly mapped to the output.

Furthermore the screen orientation is passed to the Device and a
calibration matrix is set accordingly. Thus a transformed screen has the
touch screen transformed accordingly.

Please note that this only affects libinput on Wayland and not on X11!
The x11 standalone platform needs to gain similar code.

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin created this revision.Nov 10 2017, 5:14 PM
Restricted Application added a project: KWin. · View Herald TranscriptNov 10 2017, 5:14 PM
Restricted Application added subscribers: kwin, plasma-devel. · View Herald Transcript

One minor comment (the third one), otherwise all good.

libinput/connection.cpp
396

not that it's a problem, but why?
You have screens mocked already.

398–399

if you fetch the geometry here you'll get both the size and topLeft in an easier to read way.

489

you're not updating in deviceAdded(), so hypothetically if one adds a touch screen at runtime, and plugs in the HDMI cable before the USB cable it won't have the right screen.

You could put this method (and the screens changed connect) in Device as you're not doing anything with Connection in this method.

graesslin added inline comments.Nov 10 2017, 9:31 PM
libinput/connection.cpp
396

It's failing to compile in tests/ directory. There I don't have the mockscreens, so I didn't think of it. Will try with the mockscreens. Thanks for the suggestion.

489

You could put this method (and the screens changed connect) in Device as you're not doing anything with Connection in this method.

I didn't want to add the screens dependency to Device. I need it in Connection for the touch point translation, so I added it there. Device itself doesn't have any dependencies of KWin yet, Connection is kind of the "firewall" between them.

graesslin marked an inline comment as done.Nov 10 2017, 9:54 PM
graesslin added inline comments.
libinput/connection.cpp
396

Didn't get it to compile with the mockscreens.

graesslin updated this revision to Diff 22175.Nov 11 2017, 7:32 AM

Use screens()->geometry() instead of size

Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptNov 11 2017, 7:32 AM
graesslin updated this revision to Diff 22237.Nov 12 2017, 8:23 PM

Handle deviceAdded

Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptNov 12 2017, 8:23 PM

Mostly ship it, but I noticed something in the docs when I was checking the matrices.

libinput/device.cpp
482

Shouldn't we be multiplying the default matrix for the device by the matrix you're generating here then setting that?

If a user has set a static calibration we want to keep that.

graesslin added inline comments.Nov 13 2017, 5:30 AM
libinput/device.cpp
482

Hmm, you might be right. That's something I didn't think about. Only took the matrices provided in the docs.

graesslin marked 2 inline comments as done.Dec 23 2017, 9:17 AM
Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptDec 23 2017, 9:17 AM
graesslin updated this revision to Diff 24319.Dec 23 2017, 9:19 AM

Multiply with default calibration matrix.

In order to simplify the matrix multiplication the definitions of the matrices are changed to QMatrix4x4.

Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptDec 23 2017, 9:19 AM
davidedmundson accepted this revision.Dec 23 2017, 8:35 PM
This revision is now accepted and ready to land.Dec 23 2017, 8:35 PM
Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptDec 23 2017, 8:35 PM
This revision was automatically updated to reflect the committed changes.
Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptDec 24 2017, 9:10 AM