From e50416066cab4be7df8382bd224d9e4ddd7a903a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 12 Jan 2012 08:53:13 +0100 Subject: Added application flags to translate between touch and mouse events. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current way we do it of having the platform or touch plugin send both mouse and touch events is not ideal. There's no good way to write an application that works sanely both on a touch-only device and on a desktop except by restricting yourself to only handling mouse events. If you try to handle touch events you don't get any events at all on desktop, and if you try to handle both, you end up getting duplicate events on touch devices. Instead, we should get rid of the code in the plugins that automatically sends mouse events translated from touch events. This change enables that by making the behaviour fully configurable in QtGui. Two new application attributes are added to explicitly say whether unhandled touch events should be sent as synthesized mouse events and vice versa, and no duplicates are automatically sent as the current situation. Synthesized mouse events are enabled by default. We also get rid of the QTouchEvent::TouchPoint::Primary flag, which was only used to signal that the windowing system automatically generated mouse events for that touch point. Now we only generate mouse events from the first touch point in the list. Change-Id: I8e20f3480407ca8c31b42de0a4d2b319e1346b65 Reviewed-by: Laszlo Agocs Reviewed-by: Jocelyn Turcotte Reviewed-by: Tor Arne Vestbø Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll Reviewed-by: Denis Dzyubenko --- src/corelib/global/qnamespace.h | 2 ++ src/corelib/global/qnamespace.qdoc | 9 +++++++++ src/corelib/kernel/qcoreapplication.cpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index d3b048579f..ee4000498f 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -481,6 +481,8 @@ public: AA_MacDontSwapCtrlAndMeta = 7, AA_Use96Dpi = 8, AA_X11InitThreads = 10, + AA_SynthesizeTouchForUnhandledMouseEvents = 11, + AA_SynthesizeMouseForUnhandledTouchEvents = 12, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 3c2697e1f8..3add1a48c7 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -167,6 +167,15 @@ construction in order to make Xlib calls thread-safe. This attribute must be set before QApplication is constructed. + \value AA_SynthesizeTouchForUnhandledMouseEvents All mouse events + that are not accepted by the application will be translated + to touch events instead. + + \value AA_SynthesizeMouseForUnhandledTouchEvents All touch events + that are not accepted by the application will be translated + to left button mouse events instead. This attribute is enabled + by default. + \omitvalue AA_AttributeCount */ diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 7a4618be34..05f26cc87f 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -300,7 +300,7 @@ Q_CORE_EXPORT uint qGlobalPostedEventsCount() QCoreApplication *QCoreApplication::self = 0; QAbstractEventDispatcher *QCoreApplicationPrivate::eventDispatcher = 0; -uint QCoreApplicationPrivate::attribs; +uint QCoreApplicationPrivate::attribs = (1 << Qt::AA_SynthesizeMouseForUnhandledTouchEvents); #ifdef Q_OS_UNIX Qt::HANDLE qt_application_thread_id = 0; -- cgit v1.2.3