Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[qtmozembed] Prevent touch event coordinates fluctuation. Fixes JB#57776 #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/qmozview_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,11 +1361,11 @@ void QMozViewPrivate::touchEvent(QTouchEvent *event)

// Add active touch point to cancelled touch sequence.
if (event->type() == QEvent::TouchCancel && touchPointsCount == 0) {
QMapIterator<int, QPointF> i(mActiveTouchPoints);
QMapIterator<int, QPair<QPointF, ulong>> i(mActiveTouchPoints);
EmbedTouchInput touchEnd(EmbedTouchInput::MULTITOUCH_END, timeStamp);
while (i.hasNext()) {
i.next();
QPointF pos = i.value();
QPointF pos = i.value().first;
touchEnd.touches.push_back(TouchData(i.key(),
createEmbedTouchPoint(pos),
0));
Expand All @@ -1384,7 +1384,7 @@ void QMozViewPrivate::touchEvent(QTouchEvent *event)
idHash.insert(pt.id(), i);
switch (pt.state()) {
case Qt::TouchPointPressed: {
mActiveTouchPoints.insert(pt.id(), pt.pos());
mActiveTouchPoints.insert(pt.id(), {pt.pos(), event->timestamp()});
pressedIds.append(pt.id());
break;
}
Expand All @@ -1395,8 +1395,11 @@ void QMozViewPrivate::touchEvent(QTouchEvent *event)
}
case Qt::TouchPointMoved:
case Qt::TouchPointStationary: {
mActiveTouchPoints.insert(pt.id(), pt.pos());
moveIds.append(pt.id());
QMap<int, QPair<QPointF, ulong>>::const_iterator i = mActiveTouchPoints.find(pt.id());
if (i == mActiveTouchPoints.end() || (event->timestamp() - i.value().second) > 1) {
mActiveTouchPoints.insert(pt.id(), {pt.pos(), event->timestamp()});
moveIds.append(pt.id());
}
break;
}
default:
Expand Down
3 changes: 2 additions & 1 deletion src/qmozview_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ public Q_SLOTS:
QPointF mLastPos;
QPointF mSecondLastPos;
QPointF mLastStationaryPos;
QMap<int, QPointF> mActiveTouchPoints;
// <id, <pos, timestamp>>
QMap<int, QPair<QPointF, ulong>> mActiveTouchPoints;
bool mCanFlick;
bool mPendingTouchEvent;
QString mUrl;
Expand Down