summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2020-01-03 12:22:09 +0100
committerPaul Olav Tvete <paul.tvete@qt.io>2020-01-08 14:47:56 +0100
commit7542dc765002d0512ed56f23f9f5727c77ae7aff (patch)
treefb347b6a8fcacdf91ddbce18484a41fce8e04bfc
parent3b6216927bc0116512b1818b6642ae3361e2455c (diff)
Don't use deprecated handleMouseEvent()
The new version takes the event type and the button responsible as arguments. This commit adds logic to figure those out when mapping touch events to mouse events. Change-Id: Iadd1cf33aed12a05fcd28c74e2439ac8ac00f632 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r--src/client/qwaylandtouch.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/client/qwaylandtouch.cpp b/src/client/qwaylandtouch.cpp
index b79f5cf5b..8f56e7aa6 100644
--- a/src/client/qwaylandtouch.cpp
+++ b/src/client/qwaylandtouch.cpp
@@ -170,17 +170,23 @@ void QWaylandTouchExtension::sendTouchEvent()
states |= mTouchPoints.at(i).state;
if (mFlags & QT_TOUCH_EXTENSION_FLAGS_MOUSE_FROM_TOUCH) {
- if (states == Qt::TouchPointPressed)
+ const bool firstPress = states == Qt::TouchPointPressed;
+ if (firstPress)
mMouseSourceId = mTouchPoints.first().id;
for (int i = 0; i < mTouchPoints.count(); ++i) {
const QWindowSystemInterface::TouchPoint &tp(mTouchPoints.at(i));
if (tp.id == mMouseSourceId) {
- Qt::MouseButtons buttons = tp.state == Qt::TouchPointReleased ? Qt::NoButton : Qt::LeftButton;
+ const bool released = tp.state == Qt::TouchPointReleased;
+ Qt::MouseButtons buttons = released ? Qt::NoButton : Qt::LeftButton;
+ QEvent::Type eventType = firstPress ? QEvent::MouseButtonPress
+ : released ? QEvent::MouseButtonRelease
+ : QEvent::MouseMove;
mLastMouseGlobal = tp.area.center();
QPoint globalPoint = mLastMouseGlobal.toPoint();
QPointF delta = mLastMouseGlobal - globalPoint;
mLastMouseLocal = mTargetWindow->mapFromGlobal(globalPoint) + delta;
- QWindowSystemInterface::handleMouseEvent(mTargetWindow, mTimestamp, mLastMouseLocal, mLastMouseGlobal, buttons);
+ QWindowSystemInterface::handleMouseEvent(mTargetWindow, mTimestamp, mLastMouseLocal, mLastMouseGlobal,
+ buttons, Qt::LeftButton, eventType);
if (buttons == Qt::NoButton)
mMouseSourceId = -1;
break;
@@ -200,7 +206,7 @@ void QWaylandTouchExtension::touchCanceled()
mTouchPoints.clear();
mPrevTouchPoints.clear();
if (mMouseSourceId != -1)
- QWindowSystemInterface::handleMouseEvent(mTargetWindow, mTimestamp, mLastMouseLocal, mLastMouseGlobal, Qt::NoButton);
+ QWindowSystemInterface::handleMouseEvent(mTargetWindow, mTimestamp, mLastMouseLocal, mLastMouseGlobal, Qt::NoButton, Qt::LeftButton, QEvent::MouseButtonRelease);
}
void QWaylandTouchExtension::touch_extension_configure(uint32_t flags)