diff options
Diffstat (limited to 'src/platformsupport/input/libinput/qlibinputtouch.cpp')
-rw-r--r-- | src/platformsupport/input/libinput/qlibinputtouch.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp index 32d1df5b89..ed531f5773 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch.cpp +++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp @@ -38,7 +38,7 @@ ****************************************************************************/ #include "qlibinputtouch_p.h" -#include "qtouchoutputmapping_p.h" +#include "qoutputmapping_p.h" #include <libinput.h> #include <QtGui/QGuiApplication> #include <QtGui/QPointingDevice> @@ -68,9 +68,8 @@ QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e return &m_devState[dev]; } -QPointF QLibInputTouch::getPos(libinput_event_touch *e) +QRect QLibInputTouch::screenGeometry(DeviceState *state) { - DeviceState *state = deviceState(e); QScreen *screen = QGuiApplication::primaryScreen(); if (!state->m_screenName.isEmpty()) { if (!m_screen) { @@ -85,7 +84,13 @@ QPointF QLibInputTouch::getPos(libinput_event_touch *e) if (m_screen) screen = m_screen; } - const QRect geom = QHighDpi::toNativePixels(screen->geometry(), screen); + return QHighDpi::toNativePixels(screen->geometry(), screen); +} + +QPointF QLibInputTouch::getPos(libinput_event_touch *e) +{ + DeviceState *state = deviceState(e); + QRect geom = screenGeometry(state); 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); @@ -101,19 +106,26 @@ void QLibInputTouch::registerDevice(libinput_device *dev) qCDebug(qLcLibInput, "libinput: registerDevice %s - %s", qPrintable(devNode), qPrintable(devName)); - QTouchOutputMapping mapping; - if (mapping.load()) { - m_devState[dev].m_screenName = mapping.screenNameForDeviceNode(devNode); - if (!m_devState[dev].m_screenName.isEmpty()) - qCDebug(qLcLibInput, "libinput: Mapping device %s to screen %s", - qPrintable(devNode), qPrintable(m_devState[dev].m_screenName)); + QOutputMapping *mapping = QOutputMapping::get(); + QRect geom; + if (mapping->load()) { + m_devState[dev].m_screenName = mapping->screenNameForDeviceNode(devNode); + if (!m_devState[dev].m_screenName.isEmpty()) { + geom = screenGeometry(&m_devState[dev]); + qCDebug(qLcLibInput) << "libinput: Mapping device" << devNode + << "to screen" << m_devState[dev].m_screenName + << "with geometry" << geom; + } } QPointingDevice *&td = m_devState[dev].m_touchDevice; td = new QPointingDevice(devName, udev_device_get_devnum(udev_device), QInputDevice::DeviceType::TouchScreen, QPointingDevice::PointerType::Finger, QPointingDevice::Capability::Position | QPointingDevice::Capability::Area, 16, 0); - QPointingDevicePrivate::get(td)->busId = QString::fromLocal8Bit(udev_device_get_syspath(udev_device)); // TODO is that the best to choose? + auto devPriv = QPointingDevicePrivate::get(td); + devPriv->busId = QString::fromLocal8Bit(udev_device_get_syspath(udev_device)); // TODO is that the best to choose? + if (!geom.isNull()) + devPriv->setAvailableVirtualGeometry(geom); QWindowSystemInterface::registerInputDevice(td); } |