diff options
author | Romain Pokrzywka <romain.pokrzywka@bluescape.com> | 2015-09-17 13:33:46 -0700 |
---|---|---|
committer | Romain Pokrzywka <romain.pokrzywka@gmail.com> | 2015-11-26 00:51:03 +0000 |
commit | 8d6fe1a37193ace073971820a6a6b22379e3fa95 (patch) | |
tree | e4e9405f59dd2ba9a4c3ff24f867ac7bd9145413 /src/gui/kernel/qguiapplication.cpp | |
parent | 50cd0daf29d434b78cc70bbf732ee33b2bc18600 (diff) |
Accept concurrent input from multiple tablet devices in QGuiApplication
As a follow-up to 352c357e6f0785c0775a85151d6716b47aea1006 enabling
support for multiple evdevtablet plugins at runtime (one per device),
we also need to adjust the way QGuiApplication handles the events
received from those plugins, in particular when multiple devices
are sending tablet events concurrently.
Replace the static members in QGuiApplication by a vector storing
the same data per-device, so tablet press/release events can be
recognized independently.
Change-Id: Ie0975cdb03a8f6d05903e2e2e57ceb9de73a74a4
Reviewed-by: Jake Petroules <jake.petroules@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 0b1c49dd60..248a7d0d1d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -124,8 +124,6 @@ Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; QPointF QGuiApplicationPrivate::lastCursorPosition(qInf(), qInf()); -Qt::MouseButtons QGuiApplicationPrivate::tabletState = Qt::NoButton; -QWindow *QGuiApplicationPrivate::tabletPressTarget = 0; QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; QString QGuiApplicationPrivate::styleOverride; @@ -134,6 +132,8 @@ Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationI bool QGuiApplicationPrivate::highDpiScalingUpdated = false; +QVector<QGuiApplicationPrivate::TabletPointData> QGuiApplicationPrivate::tabletDevicePoints; + QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; @@ -2198,12 +2198,26 @@ void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate: QGuiApplication::sendSpontaneousEvent(qApp, &event); } +QGuiApplicationPrivate::TabletPointData &QGuiApplicationPrivate::tabletDevicePoint(qint64 deviceId) +{ + for (int i = 0; i < tabletDevicePoints.size(); ++i) { + TabletPointData &pointData = tabletDevicePoints[i]; + if (pointData.deviceId == deviceId) + return pointData; + } + + tabletDevicePoints.append(TabletPointData(deviceId)); + return tabletDevicePoints.last(); +} + void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e) { #ifndef QT_NO_TABLETEVENT + TabletPointData &pointData = tabletDevicePoint(e->uid); + QEvent::Type type = QEvent::TabletMove; - if (e->buttons != tabletState) - type = (e->buttons > tabletState) ? QEvent::TabletPress : QEvent::TabletRelease; + if (e->buttons != pointData.state) + type = (e->buttons > pointData.state) ? QEvent::TabletPress : QEvent::TabletRelease; QWindow *window = e->window.data(); modifier_buttons = e->modifiers; @@ -2219,14 +2233,14 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T } if (!window) return; - tabletPressTarget = window; + pointData.target = window; } else { if (e->nullWindow()) { - window = tabletPressTarget; + window = pointData.target; localValid = false; } if (type == QEvent::TabletRelease) - tabletPressTarget = 0; + pointData.target = Q_NULLPTR; if (!window) return; } @@ -2235,7 +2249,7 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T QPointF delta = e->global - e->global.toPoint(); local = window->mapFromGlobal(e->global.toPoint()) + delta; } - Qt::MouseButtons stateChange = e->buttons ^ tabletState; + Qt::MouseButtons stateChange = e->buttons ^ pointData.state; Qt::MouseButton button = Qt::NoButton; for (int check = Qt::LeftButton; check <= int(Qt::MaxMouseButton); check = check << 1) { if (check & stateChange) { @@ -2249,7 +2263,7 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T e->modifiers, e->uid, button, e->buttons); ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(window, &ev); - tabletState = e->buttons; + pointData.state = e->buttons; #else Q_UNUSED(e) #endif @@ -2261,7 +2275,7 @@ void QGuiApplicationPrivate::processTabletEnterProximityEvent(QWindowSystemInter QTabletEvent ev(QEvent::TabletEnterProximity, QPointF(), QPointF(), e->device, e->pointerType, 0, 0, 0, 0, 0, 0, - Qt::NoModifier, e->uid, Qt::NoButton, tabletState); + Qt::NoModifier, e->uid, Qt::NoButton, tabletDevicePoint(e->uid).state); ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(qGuiApp, &ev); #else @@ -2275,7 +2289,7 @@ void QGuiApplicationPrivate::processTabletLeaveProximityEvent(QWindowSystemInter QTabletEvent ev(QEvent::TabletLeaveProximity, QPointF(), QPointF(), e->device, e->pointerType, 0, 0, 0, 0, 0, 0, - Qt::NoModifier, e->uid, Qt::NoButton, tabletState); + Qt::NoModifier, e->uid, Qt::NoButton, tabletDevicePoint(e->uid).state); ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(qGuiApp, &ev); #else |