summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qguiapplication.cpp8
-rw-r--r--src/gui/kernel/qguiapplication_p.h2
-rw-r--r--src/widgets/kernel/qapplication.cpp8
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp6
4 files changed, 17 insertions, 7 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index c2e19ca2a8..432929fec5 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -602,6 +602,12 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking
return false;
}
+bool QGuiApplicationPrivate::synthesizeMouseFromTouchEventsEnabled()
+{
+ return QCoreApplication::testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)
+ && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool();
+}
+
/*!
Returns the QWindow that receives events tied to focus,
such as key events.
@@ -2054,7 +2060,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
}
QGuiApplication::sendSpontaneousEvent(w, &touchEvent);
- if (!e->synthetic && !touchEvent.isAccepted() && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) {
+ if (!e->synthetic && !touchEvent.isAccepted() && synthesizeMouseFromTouchEventsEnabled()) {
// exclude touchpads as those generate their own mouse events
if (touchEvent.device()->type() != QTouchDevice::TouchPad) {
Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton;
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 22d95b2121..376890ef47 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -191,6 +191,8 @@ public:
static void updateBlockedStatus(QWindow *window);
virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const;
+ static bool synthesizeMouseFromTouchEventsEnabled();
+
static Qt::MouseButtons buttons;
static ulong mousePressTime;
static Qt::MouseButton mousePressButton;
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index ac25d3ed7f..02fcfde59e 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3210,7 +3210,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
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())
+ if (!touchEvent->isAccepted() && QGuiApplicationPrivate::synthesizeMouseFromTouchEventsEnabled())
res = d->translateTouchToMouse(widget, touchEvent);
break;
}
@@ -3237,7 +3237,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
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()) {
+ if (!touchEvent->isAccepted() && QGuiApplicationPrivate::synthesizeMouseFromTouchEventsEnabled()) {
res = d->translateTouchToMouse(widget, touchEvent);
eventAccepted = touchEvent->isAccepted();
if (eventAccepted)
@@ -3801,10 +3801,6 @@ private:
bool QApplicationPrivate::translateTouchToMouse(QWidget *widget, QTouchEvent *event)
{
- // Check if the platform wants synthesized mouse events.
- if (!QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool())
- return false;
-
Q_FOREACH (const QTouchEvent::TouchPoint &p, event->touchPoints()) {
const QEvent::Type eventType = (p.state() & Qt::TouchPointPressed) ? QEvent::MouseButtonPress
: (p.state() & Qt::TouchPointReleased) ? QEvent::MouseButtonRelease
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index b67920737e..29c72cc02e 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -41,6 +41,8 @@
#include <qwindow.h>
#include <qpa/qwindowsysteminterface.h>
+#include <qpa/qplatformintegration.h>
+#include <private/qguiapplication_p.h>
#include <QtTest/QtTest>
@@ -484,6 +486,8 @@ void tst_QWindow::testInputEvents()
void tst_QWindow::touchToMouseTranslation()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool())
+ QSKIP("Mouse events are synthesized by the system on this platform.");
InputTestWindow window;
window.ignoreTouch = true;
window.setGeometry(80, 80, 40, 40);
@@ -684,6 +688,8 @@ void tst_QWindow::touchCancel()
void tst_QWindow::touchCancelWithTouchToMouse()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool())
+ QSKIP("Mouse events are synthesized by the system on this platform.");
InputTestWindow window;
window.ignoreTouch = true;
window.setGeometry(80, 80, 40, 40);