diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-08-09 15:48:12 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-08-11 21:11:43 +0000 |
commit | dfae6a7593a6bb4ad6accc30d6aaf01a98bc2a6f (patch) | |
tree | 612de4a8c99bb1a9cfe49e8daf9e6712e1622dbb /src/platformsupport/input/libinput/qlibinputtouch.cpp | |
parent | 2afead0211302799519abee5c164ae0602a7e13b (diff) |
evdevtouch: Enable touch in multi-screen eglfs environments
Parse the touchDevice property from the KMS/DRM config file. When all
outputs have an explicitly specified index in the virtual desktop, we
can set up a mapping between the device node and the screen index. It
is somewhat fragile (device nodes may change, requires explicit
virtualIndex properties for all outputs, etc.) but better than
nothing.
For example, having the screen on DisplayPort as primary and the
touchscreen on HDMI as the secondary screen breaks by default because
touching the second screen generates touch (and synthesized mouse)
events for the first screen. Assuming the touchscreen is
/dev/input/event5, the issue can now be fixed by setting
QT_QPA_EGLFS_KMS_CONFIG with a configuration like the following:
{
"device": "drm-nvdc",
"outputs": [
{
"name": "HDMI1",
"touchDevice": "/dev/input/event5",
"virtualIndex": 1
},
{
"name": "DP1",
"virtualIndex": 0
}
]
}
Task-number: QTBUG-54151
Change-Id: If97fa18a65599ccfe64ce408ea43086ec3863682
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/platformsupport/input/libinput/qlibinputtouch.cpp')
-rw-r--r-- | src/platformsupport/input/libinput/qlibinputtouch.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp index 1e82ce5c91..42925a18e1 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch.cpp +++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp @@ -64,11 +64,14 @@ QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e static inline QPointF getPos(libinput_event_touch *e) { + // TODO Map to correct screen using QTouchOutputMapping. + // Perhaps investigate libinput_device_get_output_name as well. + // For now just use the primary screen. QScreen *screen = QGuiApplication::primaryScreen(); - const QSize screenSize = QHighDpi::toNativePixels(screen->geometry().size(), screen); - const double x = libinput_event_touch_get_x_transformed(e, screenSize.width()); - const double y = libinput_event_touch_get_y_transformed(e, screenSize.height()); - return QPointF(x, y); + const QRect geom = QHighDpi::toNativePixels(screen->geometry(), screen); + const double x = libinput_event_touch_get_x_transformed(e, geom.width()); + const double y = libinput_event_touch_get_y_transformed(e, geom.height()); + return geom.topLeft() + QPointF(x, y); } void QLibInputTouch::registerDevice(libinput_device *dev) |