From 885f325196de48493a604c6d13e3f360e4fefba3 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 3 May 2013 13:47:42 +0200 Subject: Enable touch events on Mac for PinchArea Enabling touch events on a window causes scroll event lag so we want to avoid avoid it as far as possible. Enable/disable on scene changes, similar to what we do with WA_AcceptTouchEvents for widgets, and in change I2e5b5e2b093cccfc5253f7228f5ec0c588c60371 for MultiPointTouchArea. Change-Id: I8cd8d172ffd93cfc4ec115917cc8662202f3b069 Reviewed-by: Gabriel de Dietrich --- src/quick/items/qquickpincharea.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/quick/items/qquickpincharea.cpp') diff --git a/src/quick/items/qquickpincharea.cpp b/src/quick/items/qquickpincharea.cpp index 0e47b61319..dc586dcaea 100644 --- a/src/quick/items/qquickpincharea.cpp +++ b/src/quick/items/qquickpincharea.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -246,11 +247,15 @@ QQuickPinchAreaPrivate::~QQuickPinchAreaPrivate() QQuickPinchArea::QQuickPinchArea(QQuickItem *parent) : QQuickItem(*(new QQuickPinchAreaPrivate), parent) + , _currentWindow(0) { Q_D(QQuickPinchArea); d->init(); setAcceptedMouseButtons(Qt::LeftButton); setFiltersChildMouseEvents(true); +#ifdef Q_OS_MAC + connect(this, &QQuickItem::windowChanged, this, &QQuickPinchArea::setTouchEventsEnabledForWindow); +#endif } QQuickPinchArea::~QQuickPinchArea() @@ -539,6 +544,27 @@ QQuickPinch *QQuickPinchArea::pinch() return d->pinch; } +void QQuickPinchArea::setTouchEventsEnabledForWindow(QWindow *window) +{ +#ifdef Q_OS_MAC + // Resolve function for enabling touch events from the (cocoa) platform plugin. + typedef void (*RegisterTouchWindowFunction)(QWindow *, bool); + RegisterTouchWindowFunction registerTouchWindow = reinterpret_cast( + QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow")); + if (!registerTouchWindow) + return; // Not necessarily an error, Qt migh be using a different platform plugin. + + // Disable touch on the old window, enable on the new window. + if (_currentWindow) + registerTouchWindow(_currentWindow, false); + if (window) + registerTouchWindow(window, true); + // Save the current window, setTouchEventsEnabledForWindow will be called + // with a null window on disable. + _currentWindow = window; +#endif +} + QT_END_NAMESPACE -- cgit v1.2.3 From 3fb03d8e0d8275349241eee619466698f6fc4825 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 6 May 2013 10:57:53 +0200 Subject: Fix warnings about unused parameters. Change-Id: I091a0369f2026ae820d623aadd13a3190d40a56b Reviewed-by: Shawn Rutledge --- src/quick/items/qquickpincharea.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/quick/items/qquickpincharea.cpp') diff --git a/src/quick/items/qquickpincharea.cpp b/src/quick/items/qquickpincharea.cpp index dc586dcaea..434eaa8723 100644 --- a/src/quick/items/qquickpincharea.cpp +++ b/src/quick/items/qquickpincharea.cpp @@ -562,6 +562,8 @@ void QQuickPinchArea::setTouchEventsEnabledForWindow(QWindow *window) // Save the current window, setTouchEventsEnabledForWindow will be called // with a null window on disable. _currentWindow = window; +#else // Q_OS_MAC + Q_UNUSED(window) #endif } -- cgit v1.2.3