From b638a7da38eba2e520a0636b9b08602a556b4849 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 14 Sep 2016 14:05:05 +0200 Subject: eglfs: Add missing virtual layout setting for DRM/KMS Just setting virtualDesktopLayout and virtualIndex are not always enough. To create more complex shapes (e.g. a T-shaped cluster) the top-left position has to be specified explicitly. Enable this via an optional virtualPos property. This also involves improving evdevtouch's mapping functionality. Instead of fragile indices, rely on the screen name instead. Change-Id: I138840779032ad9da674bfef7763adfdfc74ccd4 Reviewed-by: Andy Nichols --- .../input/evdevtouch/qevdevtouchhandler.cpp | 30 ++++++++++++++-------- .../input/shared/qtouchoutputmapping.cpp | 12 ++++----- .../input/shared/qtouchoutputmapping_p.h | 4 +-- 3 files changed, 27 insertions(+), 19 deletions(-) (limited to 'src/platformsupport/input') diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index 32ec9d5452..d53a317fc5 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -131,7 +131,8 @@ public: bool m_typeB; QTransform m_rotate; bool m_singleTouch; - int m_screenIndex; + QString m_screenName; + QPointer m_screen; }; QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, const QStringList &args) @@ -141,8 +142,7 @@ QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, co hw_range_x_min(0), hw_range_x_max(0), hw_range_y_min(0), hw_range_y_max(0), hw_pressure_min(0), hw_pressure_max(0), - m_typeB(false), m_singleTouch(false), - m_screenIndex(-1) + m_typeB(false), m_singleTouch(false) { m_forceToActiveWindow = args.contains(QLatin1String("force_window")); } @@ -301,10 +301,10 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const QTouchOutputMapping mapping; if (mapping.load()) { - d->m_screenIndex = mapping.screenIndexForDeviceNode(d->deviceNode); - if (d->m_screenIndex >= 0) - qCDebug(qLcEvdevTouch, "evdevtouch: Mapping device %s to screen index %d", - qPrintable(d->deviceNode), d->m_screenIndex); + d->m_screenName = mapping.screenNameForDeviceNode(d->deviceNode); + if (!d->m_screenName.isEmpty()) + qCDebug(qLcEvdevTouch, "evdevtouch: Mapping device %s to screen %s", + qPrintable(d->deviceNode), qPrintable(d->m_screenName)); } registerTouchDevice(); @@ -673,10 +673,18 @@ void QEvdevTouchScreenData::reportPoints() // geometry in the full virtual desktop space, there is nothing else // left to do since qguiapp will handle the rest. QScreen *screen = QGuiApplication::primaryScreen(); - if (m_screenIndex >= 0) { - const QList screens = QGuiApplication::screens(); - if (m_screenIndex < screens.count()) - screen = screens.at(m_screenIndex); + if (!m_screenName.isEmpty()) { + if (!m_screen) { + const QList screens = QGuiApplication::screens(); + for (QScreen *s : screens) { + if (s->name() == m_screenName) { + m_screen = s; + break; + } + } + } + if (m_screen) + screen = m_screen; } winRect = QHighDpi::toNativePixels(screen->geometry(), screen); } diff --git a/src/platformsupport/input/shared/qtouchoutputmapping.cpp b/src/platformsupport/input/shared/qtouchoutputmapping.cpp index 55c1dc34f4..0a1afd4739 100644 --- a/src/platformsupport/input/shared/qtouchoutputmapping.cpp +++ b/src/platformsupport/input/shared/qtouchoutputmapping.cpp @@ -71,21 +71,21 @@ bool QTouchOutputMapping::load() const QVariantMap output = outputs.at(i).toObject().toVariantMap(); if (!output.contains(QStringLiteral("touchDevice"))) continue; - if (!output.contains(QStringLiteral("virtualIndex"))) { - qWarning("evdevtouch: Output %d specifies touchDevice but not virtualIndex, this is wrong", i); + if (!output.contains(QStringLiteral("name"))) { + qWarning("evdevtouch: Output %d specifies touchDevice but not name, this is wrong", i); continue; } const QString &deviceNode = output.value(QStringLiteral("touchDevice")).toString(); - const int screenIndex = output.value(QStringLiteral("virtualIndex")).toInt(); - m_screenIndexTable.insert(deviceNode, screenIndex); + const QString &screenName = output.value(QStringLiteral("name")).toString(); + m_screenTable.insert(deviceNode, screenName); } return true; } -int QTouchOutputMapping::screenIndexForDeviceNode(const QString &deviceNode) +QString QTouchOutputMapping::screenNameForDeviceNode(const QString &deviceNode) { - return m_screenIndexTable.value(deviceNode, -1); + return m_screenTable.value(deviceNode); } QT_END_NAMESPACE diff --git a/src/platformsupport/input/shared/qtouchoutputmapping_p.h b/src/platformsupport/input/shared/qtouchoutputmapping_p.h index 74999d93ce..94d4dbc3b1 100644 --- a/src/platformsupport/input/shared/qtouchoutputmapping_p.h +++ b/src/platformsupport/input/shared/qtouchoutputmapping_p.h @@ -60,10 +60,10 @@ class QTouchOutputMapping { public: bool load(); - int screenIndexForDeviceNode(const QString &deviceNode); + QString screenNameForDeviceNode(const QString &deviceNode); private: - QHash m_screenIndexTable; + QHash m_screenTable; }; QT_END_NAMESPACE -- cgit v1.2.3