diff options
| author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2024-11-06 16:50:06 +0100 |
|---|---|---|
| committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2024-11-07 20:49:19 +0100 |
| commit | 0a40266788021aaa2f501aeef6db2e222669c6e9 (patch) | |
| tree | 56001f871766c30d1a92acc9fa2671bdfe0d020a /src | |
| parent | 22c0cf80c8edf1871be579bde5524f1f89b45db8 (diff) | |
QCocoaDrag: consistently update the last view and event pointers
As pointed out in the qcocoadrag.h header, we need QCocoaDrag to record
the original event and view when handling an event in QNSView. For that,
NSView's handleMouseEvent implementation called setLastMouseEvent.
This was not done for tablet or touch events, although both of those
event types might initiate and participate in drag'n'drop operation. Do
that consistently now, and rename the setter accordingly to
setLastInputEvent.
Task-number: QTBUG-116554
Pick-to: 6.8 6.5
Change-Id: I9646adbec3a2301ebca123f0f25328db63c782a8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/platforms/cocoa/qcocoadrag.h | 2 | ||||
| -rw-r--r-- | src/plugins/platforms/cocoa/qcocoadrag.mm | 2 | ||||
| -rw-r--r-- | src/plugins/platforms/cocoa/qnsview_mouse.mm | 2 | ||||
| -rw-r--r-- | src/plugins/platforms/cocoa/qnsview_tablet.mm | 3 | ||||
| -rw-r--r-- | src/plugins/platforms/cocoa/qnsview_touch.mm | 12 |
5 files changed, 18 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.h b/src/plugins/platforms/cocoa/qcocoadrag.h index dedf8a7fd9c..f470fa39a9f 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.h +++ b/src/plugins/platforms/cocoa/qcocoadrag.h @@ -35,7 +35,7 @@ public: * to meet NSView dragImage:at guarantees, we need to record the original * event and view when handling an event in QNSView */ - void setLastMouseEvent(NSEvent *event, NSView *view); + void setLastInputEvent(NSEvent *event, NSView *view); void setAcceptedAction(Qt::DropAction act); void exitDragLoop(); diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm index 3a9f5a87941..3b736db39b3 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.mm +++ b/src/plugins/platforms/cocoa/qcocoadrag.mm @@ -31,7 +31,7 @@ QCocoaDrag::~QCocoaDrag() [m_lastEvent release]; } -void QCocoaDrag::setLastMouseEvent(NSEvent *event, NSView *view) +void QCocoaDrag::setLastInputEvent(NSEvent *event, NSView *view) { [m_lastEvent release]; m_lastEvent = [event copy]; diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm index fd8ac81bed2..845b085b219 100644 --- a/src/plugins/platforms/cocoa/qnsview_mouse.mm +++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm @@ -117,7 +117,7 @@ static const QPointingDevice *pointingDeviceFor(qint64 deviceID) ulong timestamp = [theEvent timestamp] * 1000; QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); - nativeDrag->setLastMouseEvent(theEvent, self); + nativeDrag->setLastInputEvent(theEvent, self); const auto modifiers = QAppleKeyMapper::fromCocoaModifiers(theEvent.modifierFlags); auto button = cocoaButton2QtButton(theEvent); diff --git a/src/plugins/platforms/cocoa/qnsview_tablet.mm b/src/plugins/platforms/cocoa/qnsview_tablet.mm index 4c6e351b3f4..09553aee5f6 100644 --- a/src/plugins/platforms/cocoa/qnsview_tablet.mm +++ b/src/plugins/platforms/cocoa/qnsview_tablet.mm @@ -28,6 +28,9 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceMap, devicesInProximity) ulong timestamp = [theEvent timestamp] * 1000; + QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); + nativeDrag->setLastInputEvent(theEvent, self); + QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint: &windowPoint andScreenPoint: &screenPoint]; diff --git a/src/plugins/platforms/cocoa/qnsview_touch.mm b/src/plugins/platforms/cocoa/qnsview_touch.mm index 97ed5b76249..5d93d2c688a 100644 --- a/src/plugins/platforms/cocoa/qnsview_touch.mm +++ b/src/plugins/platforms/cocoa/qnsview_touch.mm @@ -37,6 +37,10 @@ Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch") return; const NSTimeInterval timestamp = [event timestamp]; + + QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); + nativeDrag->setLastInputEvent(event, self); + const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points << "from device" << Qt::hex << [event deviceID]; QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>( @@ -51,6 +55,10 @@ Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch") return; const NSTimeInterval timestamp = [event timestamp]; + + QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); + nativeDrag->setLastInputEvent(event, self); + const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points << "from device" << Qt::hex << [event deviceID]; QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>( @@ -65,6 +73,10 @@ Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch") return; const NSTimeInterval timestamp = [event timestamp]; + + QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); + nativeDrag->setLastInputEvent(event, self); + const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points << "from device" << Qt::hex << [event deviceID]; QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>( |
