summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-11-18 17:01:15 +0100
committerShawn Rutledge <shawn.rutledge@digia.com>2014-11-27 09:29:17 +0100
commitc124ac42c779900b22c413ea629a4ff3f284d2ba (patch)
treecf78bfea91ce0675aed657d77c9d978080d8cdac /src/plugins/platforms
parentcc1d9671b391f99a5fe5d690c92e940ecc86d6de (diff)
OS X: remove use of Carbon API for scroll events; fix ScrollBegin
NSEventPhaseMayBegin doesn't happen with some types of trackpads, so don't treat NSEventPhaseBegan as Qt::ScrollUpdate. Change-Id: Ica97d49692a904e20c8eb0250760e6370311ee40 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h1
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm25
2 files changed, 14 insertions, 12 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index 8d8df13dc3..ffa616f968 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -74,6 +74,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QNSViewMouseMoveHelper);
NSString *m_inputSource;
QNSViewMouseMoveHelper *m_mouseMoveHelper;
bool m_resendKeyEvent;
+ bool m_scrolling;
}
- (id)init;
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 0ce5b3b332..798e349538 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@@ -160,6 +160,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
m_inputSource = 0;
m_mouseMoveHelper = [[QNSViewMouseMoveHelper alloc] initWithView:self];
m_resendKeyEvent = false;
+ m_scrolling = false;
if (!touchDevice) {
touchDevice = new QTouchDevice;
@@ -1265,12 +1266,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
{
if (m_window->flags() & Qt::WindowTransparentForInput)
return [super scrollWheel:theEvent];
- const EventRef carbonEvent = (EventRef)[theEvent eventRef];
- const UInt32 carbonEventKind = carbonEvent ? ::GetEventKind(carbonEvent) : 0;
- const bool scrollEvent = carbonEventKind == kEventMouseScroll;
QPoint angleDelta;
- if (scrollEvent) {
+ if ([theEvent hasPreciseScrollingDeltas]) {
// The mouse device contains pixel scroll wheel support (Mighty Mouse, Trackpad).
// Since deviceDelta is delivered as pixels rather than degrees, we need to
// convert from pixels to degrees in a sensible manner.
@@ -1280,7 +1278,6 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
angleDelta.setX([theEvent scrollingDeltaX] * pixelsToDegrees);
angleDelta.setY([theEvent scrollingDeltaY] * pixelsToDegrees);
} else {
- // carbonEventKind == kEventMouseWheelMoved
// Remove acceleration, and use either -120 or 120 as delta:
angleDelta.setX(qBound(-120, int([theEvent deltaX] * 10000), 120));
angleDelta.setY(qBound(-120, int([theEvent deltaY] * 10000), 120));
@@ -1321,16 +1318,20 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
// On 10.8 and above, MayBegin is likely to happen. We treat it the same as an actual begin.
- if (phase == NSEventPhaseMayBegin)
+ if (phase == NSEventPhaseMayBegin) {
+ m_scrolling = true;
ph = Qt::ScrollBegin;
- } else
+ }
+ }
#endif
- if (phase == NSEventPhaseBegan) {
- // On 10.7, MayBegin will not happen, so Began is the actual beginning.
+ if (phase == NSEventPhaseBegan) {
+ // If MayBegin did not happen, Began is the actual beginning.
+ if (!m_scrolling)
ph = Qt::ScrollBegin;
- }
- if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled) {
+ m_scrolling = true;
+ } else if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled) {
ph = Qt::ScrollEnd;
+ m_scrolling = false;
}
QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph);