summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2013-01-24 11:24:00 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-26 19:22:01 +0100
commit03d057ff01332333b98f5298c3d0bd85b5604ac9 (patch)
tree2f0922111950af7e5335f48dbc6e3ae58d2522b9 /src/widgets
parentb2c73c73cd0a68aae0586cf447c2612c13aeb52c (diff)
Cocoa: Make touch events work again.
Bring back the ref-counted enable on enter/leave workaround we had in Qt 4: If any widget in a window sets WA_AcceptTouchEvents then that window will start processing touch events. Enabling touch events has implications for delivery of other events, for example by causing scrolling event lag. Change-Id: I307488937f417612eff624bf9892b82a7f69c1b7 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/kernel/qapplication.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 22133214df..ac25d3ed7f 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3367,6 +3367,34 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
break;
}
#endif // QT_NO_GESTURES
+#ifdef Q_OS_MAC
+ // Enable touch events on enter, disable on leave.
+ typedef void (*RegisterTouchWindowFn)(QWindow *, bool);
+ case QEvent::Enter:
+ if (receiver->isWidgetType()) {
+ QWidget *w = static_cast<QWidget *>(receiver);
+ if (w->testAttribute(Qt::WA_AcceptTouchEvents)) {
+ RegisterTouchWindowFn registerTouchWindow = reinterpret_cast<RegisterTouchWindowFn>
+ (platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow"));
+ if (registerTouchWindow)
+ registerTouchWindow(w->window()->windowHandle(), true);
+ }
+ }
+ res = d->notify_helper(receiver, e);
+ break;
+ case QEvent::Leave:
+ if (receiver->isWidgetType()) {
+ QWidget *w = static_cast<QWidget *>(receiver);
+ if (w->testAttribute(Qt::WA_AcceptTouchEvents)) {
+ RegisterTouchWindowFn registerTouchWindow = reinterpret_cast<RegisterTouchWindowFn>
+ (platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow"));
+ if (registerTouchWindow)
+ registerTouchWindow(w->window()->windowHandle(), false);
+ }
+ }
+ res = d->notify_helper(receiver, e);
+ break;
+#endif
default:
res = d->notify_helper(receiver, e);
break;