diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2011-01-24 09:02:51 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2011-01-24 09:02:51 (GMT) |
commit | b1c715f8214233f5b573ed58fc89c9dd70beabb4 (patch) | |
tree | bff329adc8f591e1f600fbe3fc68753bf44e00a6 /src/gui/kernel/qwidget_mac.mm | |
parent | 002e3f471025fe4f84d2dd8dd07c440808d7a839 (diff) | |
download | Qt-b1c715f8214233f5b573ed58fc89c9dd70beabb4.zip Qt-b1c715f8214233f5b573ed58fc89c9dd70beabb4.tar.gz Qt-b1c715f8214233f5b573ed58fc89c9dd70beabb4.tar.bz2 |
Add support for disabling touch on to enhance scrolling in Cocoa
On Mac/Cocoa, enabling touch on a widget slows down the scrolling
performance of the whole application. It seems Cocoa spends some
time in the background figuring out what to do with the touch
events, and whether or not it should convert them to scroll/wheel
events. Therefore, it makes sense to no subscribe for touch when
the mouse is not over the widget, This patch implements that
strategy, and the effect is huge when tested agains creator.
Rev-By: brad
Diffstat (limited to 'src/gui/kernel/qwidget_mac.mm')
-rw-r--r-- | src/gui/kernel/qwidget_mac.mm | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index f8254ec..b3450ab 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2697,8 +2697,6 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO setWSGeometry(); if (destroyid) qt_mac_destructView(destroyid); - if (q->testAttribute(Qt::WA_AcceptTouchEvents)) - registerTouchWindow(); } /*! @@ -4981,19 +4979,36 @@ void QWidgetPrivate::registerDropSite(bool on) #endif } -void QWidgetPrivate::registerTouchWindow() +void QWidgetPrivate::registerTouchWindow(bool enable) { +#ifdef QT_MAC_USE_COCOA #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_6) return; + Q_Q(QWidget); - if (!q->testAttribute(Qt::WA_WState_Created)) + if (enable == touchEventsEnabled) return; -#ifndef QT_MAC_USE_COCOA - // Needs implementation! + + QCocoaView *view = static_cast<QCocoaView *>(qt_mac_effectiveview_for(q)); + if (!view) + return; + + if (enable) { + ++view->alienTouchCount; + if (view->alienTouchCount == 1) { + touchEventsEnabled = true; + [view setAcceptsTouchEvents:YES]; + } + } else { + --view->alienTouchCount; + if (view->alienTouchCount == 0) { + touchEventsEnabled = false; + [view setAcceptsTouchEvents:NO]; + } + } #else - NSView *view = qt_mac_effectiveview_for(q); - [view setAcceptsTouchEvents:YES]; + Q_UNUSED(on); #endif #endif } |