From dfae6a7593a6bb4ad6accc30d6aaf01a98bc2a6f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 9 Aug 2016 15:48:12 +0200 Subject: 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 --- src/platformsupport/input/libinput/libinput.pri | 2 ++ src/platformsupport/input/libinput/qlibinputtouch.cpp | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/platformsupport/input/libinput') diff --git a/src/platformsupport/input/libinput/libinput.pri b/src/platformsupport/input/libinput/libinput.pri index 35d962ff3c..aeba6c725a 100644 --- a/src/platformsupport/input/libinput/libinput.pri +++ b/src/platformsupport/input/libinput/libinput.pri @@ -13,6 +13,8 @@ SOURCES += \ INCLUDEPATH += $$QMAKE_INCDIR_LIBUDEV $$QMAKE_INCDIR_LIBINPUT LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV $$QMAKE_LIBS_LIBINPUT +INCLUDEPATH += $$PWD/../shared + contains(QT_CONFIG, xkbcommon-evdev) { INCLUDEPATH += $$QMAKE_INCDIR_XKBCOMMON_EVDEV LIBS_PRIVATE += $$QMAKE_LIBS_XKBCOMMON_EVDEV 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) -- cgit v1.2.3