summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAlexander Volkov <a.volkov@rusbitech.ru>2014-12-09 18:52:24 +0300
committerAlexander Volkov <a.volkov@rusbitech.ru>2015-02-25 13:31:41 +0000
commit76922a706f0584ce2aa1a0ca758cf0c6196ea729 (patch)
treeb705f586c876189ca7495d7bd909be032b80f02d /src/gui
parentef22739f47857c185f63f87966df79d377c89577 (diff)
Decide whether to synthesize mouse events on a per device basis
Currently Qt uses the QPlatformIntegration::StyleHint SynthesizeMouseFromTouchEvents to check whether to synthesize mouse events from touch events. But not only platform plugins can produce touch events, they can be created by e.g. QTest::touchEvent() and in this case we almost definitely need synthesizing regardless of the platform. This commit introduces a QTouchDevice::MouseEmulation capability which replaces use of the QPlatformIntegration::SynthesizeMouseFromTouchEvents. So it's possible to pass QTouchDevice without this capability to QTest::touchEvent() and be sure that mouse events will be synthesized. Notice that touch pads always emulate mouse events. As a result we can activate some tests which were disabled for specific platform configurations by commits 6c1670d8c273819435867c42725c0db0eee597dc and e9760f1559361c39f269fb89f1ebd01f6ee8378d. Change-Id: Idc82fa4007a095fc1cb5934979361b0023d2b793 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qguiapplication.cpp12
-rw-r--r--src/gui/kernel/qguiapplication_p.h2
-rw-r--r--src/gui/kernel/qplatformintegration.cpp2
-rw-r--r--src/gui/kernel/qplatformintegration.h1
-rw-r--r--src/gui/kernel/qtouchdevice.cpp3
-rw-r--r--src/gui/kernel/qtouchdevice.h3
6 files changed, 8 insertions, 15 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 0d5a130dfd..61addab9d6 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -788,12 +788,6 @@ 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.
@@ -2423,9 +2417,9 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
}
QGuiApplication::sendSpontaneousEvent(w, &touchEvent);
- if (!e->synthetic() && !touchEvent.isAccepted() && synthesizeMouseFromTouchEventsEnabled()) {
- // exclude touchpads as those generate their own mouse events
- if (touchEvent.device()->type() != QTouchDevice::TouchPad) {
+ if (!e->synthetic() && !touchEvent.isAccepted() && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) {
+ // exclude devices which generate their own mouse events
+ if (!(touchEvent.device()->capabilities() & QTouchDevice::MouseEmulation)) {
Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton;
if (b == Qt::NoButton)
self->synthesizedMousePoints.clear();
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index d29ebf5f10..ddbc446759 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -190,8 +190,6 @@ 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/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index 6043ae0cfd..6147a2a53a 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -386,8 +386,6 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return QPlatformTheme::defaultThemeHint(QPlatformTheme::StartDragVelocity);
case UseRtlExtensions:
return QVariant(false);
- case SynthesizeMouseFromTouchEvents:
- return true;
case SetFocusOnTouchRelease:
return QVariant(false);
case MousePressAndHoldInterval:
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index e6a2ef6a1f..24e19f68e6 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -141,7 +141,6 @@ public:
FontSmoothingGamma,
StartDragVelocity,
UseRtlExtensions,
- SynthesizeMouseFromTouchEvents,
PasswordMaskCharacter,
SetFocusOnTouchRelease,
ShowIsMaximized,
diff --git a/src/gui/kernel/qtouchdevice.cpp b/src/gui/kernel/qtouchdevice.cpp
index cbba171276..8737825de0 100644
--- a/src/gui/kernel/qtouchdevice.cpp
+++ b/src/gui/kernel/qtouchdevice.cpp
@@ -96,6 +96,9 @@ QT_BEGIN_NAMESPACE
\value NormalizedPosition Indicates that the normalized position is available, meaning that normalizedPos()
returns a valid value.
+
+ \value MouseEmulation Indicates that the device synthesizes mouse events.
+ This enum value has been introduced in Qt 5.5.
*/
/*!
diff --git a/src/gui/kernel/qtouchdevice.h b/src/gui/kernel/qtouchdevice.h
index 4a2d05a7b9..f2157ce2d6 100644
--- a/src/gui/kernel/qtouchdevice.h
+++ b/src/gui/kernel/qtouchdevice.h
@@ -55,7 +55,8 @@ public:
Pressure = 0x0004,
Velocity = 0x0008,
RawPositions = 0x0010,
- NormalizedPosition = 0x0020
+ NormalizedPosition = 0x0020,
+ MouseEmulation = 0x0040
};
Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)