send touch update when more points begin after single touch is ignored
Otherwise, a widget can't detect pinches if the points don't start simultaneously unless it sets WA_TouchPadAcceptSingleTouchEvents. The use case is for a widget that doesn't actually want the single touch events, but only when there are two or more touchpoints. Task-number: QTBUG-42389 Change-Id: I5269d9acb93a0001c4fde02b1f7b9e0dfcc0032f Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
This commit is contained in:
parent
ea8d4869b7
commit
63f5b1a7fc
@ -4230,8 +4230,9 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent)
|
bool QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent)
|
||||||
{
|
{
|
||||||
|
bool containsPress = false;
|
||||||
for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
|
for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
|
||||||
QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i];
|
QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i];
|
||||||
|
|
||||||
@ -4244,7 +4245,11 @@ void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEven
|
|||||||
touchPoint.d->rect = rect;
|
touchPoint.d->rect = rect;
|
||||||
touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta;
|
touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta;
|
||||||
touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta;
|
touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta;
|
||||||
|
|
||||||
|
if (touchPoint.state() == Qt::TouchPointPressed)
|
||||||
|
containsPress = true;
|
||||||
}
|
}
|
||||||
|
return containsPress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QApplicationPrivate::initializeMultitouch()
|
void QApplicationPrivate::initializeMultitouch()
|
||||||
@ -4391,11 +4396,14 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
|
|||||||
QApplication::keyboardModifiers(),
|
QApplication::keyboardModifiers(),
|
||||||
it.value().first,
|
it.value().first,
|
||||||
it.value().second);
|
it.value().second);
|
||||||
updateTouchPointsForWidget(widget, &touchEvent);
|
bool containsPress = updateTouchPointsForWidget(widget, &touchEvent);
|
||||||
touchEvent.setTimestamp(timestamp);
|
touchEvent.setTimestamp(timestamp);
|
||||||
touchEvent.setWindow(window->windowHandle());
|
touchEvent.setWindow(window->windowHandle());
|
||||||
touchEvent.setTarget(widget);
|
touchEvent.setTarget(widget);
|
||||||
|
|
||||||
|
if (containsPress)
|
||||||
|
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
|
||||||
|
|
||||||
switch (touchEvent.type()) {
|
switch (touchEvent.type()) {
|
||||||
case QEvent::TouchBegin:
|
case QEvent::TouchBegin:
|
||||||
{
|
{
|
||||||
|
@ -275,7 +275,7 @@ public:
|
|||||||
QPixmap *ignore_cursor;
|
QPixmap *ignore_cursor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
|
static bool updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
|
||||||
void initializeMultitouch();
|
void initializeMultitouch();
|
||||||
void initializeMultitouch_sys();
|
void initializeMultitouch_sys();
|
||||||
void cleanupMultitouch();
|
void cleanupMultitouch();
|
||||||
|
Loading…
Reference in New Issue
Block a user