From 685dcd8527215bb0deb239964fa8ea35bd676203 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 25 Apr 2016 13:29:13 +0200 Subject: [PATCH] OSX: mark mouse events from tablet devices as synthesized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is equivalent to d7db6c6c1944894737babf3958d0cff1e6222a22 on the xcb platform. Task-number: QTBUG-51617 Change-Id: I837a764c8382244307ba6aa02bd8bde12bd08bff Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qnsview.h | 2 +- src/plugins/platforms/cocoa/qnsview.mm | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 50b456cab7..2d4ad7aad3 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -127,7 +127,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); - (void)otherMouseUp:(NSEvent *)theEvent; - (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent; -- (void)handleTabletEvent: (NSEvent *)theEvent; +- (bool)handleTabletEvent: (NSEvent *)theEvent; - (void)tabletPoint: (NSEvent *)theEvent; - (void)tabletProximity: (NSEvent *)theEvent; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 4ac34b01ff..a2f97c78dc 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -727,7 +727,7 @@ QT_WARNING_POP - (void)handleMouseEvent:(NSEvent *)theEvent { - [self handleTabletEvent: theEvent]; + bool isTabletEvent = [self handleTabletEvent: theEvent]; QPointF qtWindowPoint; QPointF qtScreenPoint; @@ -756,7 +756,8 @@ QT_WARNING_POP nativeDrag->setLastMouseEvent(theEvent, self); Qt::KeyboardModifiers keyboardModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]]; - QWindowSystemInterface::handleMouseEvent(targetView->m_window, timestamp, qtWindowPoint, qtScreenPoint, m_buttons, keyboardModifiers); + QWindowSystemInterface::handleMouseEvent(targetView->m_window, timestamp, qtWindowPoint, qtScreenPoint, m_buttons, keyboardModifiers, + isTabletEvent ? Qt::MouseEventSynthesizedByQt : Qt::MouseEventNotSynthesized); } - (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent @@ -1056,11 +1057,11 @@ struct QCocoaTabletDeviceData typedef QHash QCocoaTabletDeviceDataHash; Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash) -- (void)handleTabletEvent: (NSEvent *)theEvent +- (bool)handleTabletEvent: (NSEvent *)theEvent { NSEventType eventType = [theEvent type]; if (eventType != NSTabletPoint && [theEvent subtype] != NSTabletPointEventSubtype) - return; // Not a tablet event. + return false; // Not a tablet event. ulong timestamp = [theEvent timestamp] * 1000; @@ -1073,7 +1074,7 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash) // Error: Unknown tablet device. Qt also gets into this state // when running on a VM. This appears to be harmless; don't // print a warning. - return; + return false; } const QCocoaTabletDeviceData &deviceData = tabletDeviceDataHash->value(deviceId); @@ -1114,6 +1115,7 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash) deviceData.device, deviceData.pointerType, buttons, pressure, xTilt, yTilt, tangentialPressure, rotation, z, deviceData.uid, keyboardModifiers); + return true; } - (void)tabletPoint: (NSEvent *)theEvent