Revert "Propagate synthesized mouse events in parallel (lock-step) with touch"
This reverts commit7808ec795c
. The commit interferes with the mouse event synthesizing which was introduced ine50416066c
, and which claims to solve the same original problem: Synthesizing mouse events should be moved out from the platform plugin. The issue with7808ec795c
is that mouse events which are stolen by event filters will never get composed double click events (this is done in the QGuiApplication code), so double clicking on item views does not work with synthesized mouse events. This makes e.g.directory pickers unusable on a touch display. The test cases introduced in the original patch still pass. Task-number: QTBUG-36974 Change-Id: I0ec7c65d2a77589e60408623c2c0b20d427f0cfa Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
This commit is contained in:
parent
bd2ef8028d
commit
0b4ea1ca9c
@ -3277,30 +3277,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case QEvent::TouchUpdate:
|
||||
case QEvent::TouchEnd:
|
||||
{
|
||||
QWidget *widget = static_cast<QWidget *>(receiver);
|
||||
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
|
||||
const bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);
|
||||
|
||||
if (e->type() != QEvent::TouchUpdate && acceptTouchEvents && e->spontaneous()) {
|
||||
const QPoint localPos = touchEvent->touchPoints()[0].pos().toPoint();
|
||||
QApplicationPrivate::giveFocusAccordingToFocusPolicy(widget, e, localPos);
|
||||
}
|
||||
|
||||
touchEvent->setTarget(widget);
|
||||
touchEvent->setAccepted(acceptTouchEvents);
|
||||
|
||||
res = acceptTouchEvents && d->notify_helper(widget, touchEvent);
|
||||
|
||||
// If the touch event wasn't accepted, synthesize a mouse event and see if the widget wants it.
|
||||
if (!touchEvent->isAccepted() && QGuiApplicationPrivate::synthesizeMouseFromTouchEventsEnabled())
|
||||
res = d->translateTouchToMouse(widget, touchEvent);
|
||||
break;
|
||||
}
|
||||
|
||||
case QEvent::TouchBegin:
|
||||
// Note: TouchUpdate and TouchEnd events are never propagated
|
||||
{
|
||||
@ -3321,15 +3297,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
||||
touchEvent->setAccepted(acceptTouchEvents);
|
||||
QPointer<QWidget> p = widget;
|
||||
res = acceptTouchEvents && d->notify_helper(widget, touchEvent);
|
||||
|
||||
// If the touch event wasn't accepted, synthesize a mouse event and see if the widget wants it.
|
||||
if (!touchEvent->isAccepted() && QGuiApplicationPrivate::synthesizeMouseFromTouchEventsEnabled()) {
|
||||
res = d->translateTouchToMouse(widget, touchEvent);
|
||||
eventAccepted = touchEvent->isAccepted();
|
||||
if (eventAccepted)
|
||||
break;
|
||||
}
|
||||
|
||||
eventAccepted = touchEvent->isAccepted();
|
||||
if (p.isNull()) {
|
||||
// widget was deleted
|
||||
@ -3892,67 +3859,6 @@ QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device,
|
||||
return static_cast<QWidget *>(closestTarget);
|
||||
}
|
||||
|
||||
class WidgetAttributeSaver
|
||||
{
|
||||
public:
|
||||
explicit WidgetAttributeSaver(QWidget *widget, Qt::WidgetAttribute attribute, bool forcedValue)
|
||||
: m_widget(widget),
|
||||
m_attribute(attribute),
|
||||
m_savedValue(widget->testAttribute(attribute))
|
||||
{
|
||||
widget->setAttribute(attribute, forcedValue);
|
||||
}
|
||||
|
||||
~WidgetAttributeSaver()
|
||||
{
|
||||
m_widget->setAttribute(m_attribute, m_savedValue);
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget * const m_widget;
|
||||
const Qt::WidgetAttribute m_attribute;
|
||||
const bool m_savedValue;
|
||||
};
|
||||
|
||||
bool QApplicationPrivate::translateTouchToMouse(QWidget *widget, QTouchEvent *event)
|
||||
{
|
||||
Q_FOREACH (const QTouchEvent::TouchPoint &p, event->touchPoints()) {
|
||||
const QEvent::Type eventType = (p.state() & Qt::TouchPointPressed) ? QEvent::MouseButtonPress
|
||||
: (p.state() & Qt::TouchPointReleased) ? QEvent::MouseButtonRelease
|
||||
: (p.state() & Qt::TouchPointMoved) ? QEvent::MouseMove
|
||||
: QEvent::None;
|
||||
|
||||
if (eventType == QEvent::None)
|
||||
continue;
|
||||
|
||||
const QPoint pos = widget->mapFromGlobal(p.screenPos().toPoint());
|
||||
|
||||
QMouseEvent mouseEvent(eventType, pos, p.screenPos().toPoint(),
|
||||
Qt::LeftButton,
|
||||
(eventType == QEvent::MouseButtonRelease) ? Qt::NoButton : Qt::LeftButton,
|
||||
event->modifiers());
|
||||
mouseEvent.setAccepted(true);
|
||||
mouseEvent.setTimestamp(event->timestamp());
|
||||
|
||||
// Make sure our synthesized mouse event doesn't propagate
|
||||
// we want to control the propagation ourself to get a chance to
|
||||
// deliver a proper touch event higher up in the hierarchy if that
|
||||
// widget doesn't pick up the mouse event either.
|
||||
WidgetAttributeSaver saver(widget, Qt::WA_NoMousePropagation, true);
|
||||
|
||||
// Note it has to be a spontaneous event if we want the focus management
|
||||
// and input method support to behave properly. Quite some of the code
|
||||
// related to those aspect check for the spontaneous flag.
|
||||
const bool res = QCoreApplication::sendSpontaneousEvent(widget, &mouseEvent);
|
||||
event->setAccepted(mouseEvent.isAccepted());
|
||||
|
||||
if (mouseEvent.isAccepted())
|
||||
return res;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
|
||||
QTouchDevice *device,
|
||||
const QList<QTouchEvent::TouchPoint> &touchPoints,
|
||||
|
@ -285,7 +285,6 @@ public:
|
||||
QWidget *findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos);
|
||||
void appendTouchPoint(const QTouchEvent::TouchPoint &touchPoint);
|
||||
void removeTouchPoint(int touchPointId);
|
||||
bool translateTouchToMouse(QWidget *widget, QTouchEvent *event);
|
||||
static bool translateRawTouchEvent(QWidget *widget,
|
||||
QTouchDevice *device,
|
||||
const QList<QTouchEvent::TouchPoint> &touchPoints,
|
||||
|
Loading…
Reference in New Issue
Block a user