summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2014-02-28 11:08:48 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-04 15:59:05 +0100
commit0b4ea1ca9cff5eb398a6e473e9577b4de7d3b7c9 (patch)
tree8e649747b4b163bec30f41ee84e7beb1ccb20e1f /src/widgets
parentbd2ef8028dbe25ae0fbd36bb99600e9136238425 (diff)
Revert "Propagate synthesized mouse events in parallel (lock-step) with touch"
This reverts commit 7808ec795c5831d56dae9c4f9f7e1306489864aa. The commit interferes with the mouse event synthesizing which was introduced in e50416066cab4be7df8382bd224d9e4ddd7a903a, and which claims to solve the same original problem: Synthesizing mouse events should be moved out from the platform plugin. The issue with 7808ec795c5831d56dae9c4f9f7e1306489864aa 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>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/kernel/qapplication.cpp94
-rw-r--r--src/widgets/kernel/qapplication_p.h1
2 files changed, 0 insertions, 95 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index c01b535067..9e221c1bf4 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -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,
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 93c9ffe002..0284a613d4 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -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,