From 4c002a8343baa8453a5485ce7939569bfc5b3267 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 5 Aug 2016 11:41:47 -0700 Subject: Cocoa: Update deprecated dragging session APIs Change-Id: I06e2dd3861c4bc5d85421ac71daf188732279e77 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qnsview.mm | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 784b1ca14b..c67bcfd23b 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1913,15 +1913,18 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin return target->mapFromGlobal(source->mapToGlobal(point)); } -- (NSDragOperation) draggingSourceOperationMaskForLocal:(BOOL)isLocal +- (NSDragOperation)draggingSession:(NSDraggingSession *)session + sourceOperationMaskForDraggingContext:(NSDraggingContext)context { - Q_UNUSED(isLocal); + Q_UNUSED(session); + Q_UNUSED(context); QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); return qt_mac_mapDropActions(nativeDrag->currentDrag()->supportedActions()); } -- (BOOL) ignoreModifierKeysWhileDragging +- (BOOL)ignoreModifierKeysForDraggingSession:(NSDraggingSession *)session { + Q_UNUSED(session); // According to the "Dragging Sources" chapter on Cocoa DnD Programming // (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/DragandDrop/Concepts/dragsource.html), // if the control, option, or command key is pressed, the source’s @@ -2075,27 +2078,27 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin return response.isAccepted(); } -- (void)draggedImage:(NSImage*) img endedAt:(NSPoint) point operation:(NSDragOperation) operation +- (void)draggingSession:(NSDraggingSession *)session + endedAtPoint:(NSPoint)screenPoint + operation:(NSDragOperation)operation { - Q_UNUSED(img); + Q_UNUSED(session); Q_UNUSED(operation); QWindow *target = findEventTargetWindow(m_window); if (!target) return; -// keep our state, and QGuiApplication state (buttons member) in-sync, -// or future mouse events will be processed incorrectly + // keep our state, and QGuiApplication state (buttons member) in-sync, + // or future mouse events will be processed incorrectly NSUInteger pmb = [NSEvent pressedMouseButtons]; for (int buttonNumber = 0; buttonNumber < 32; buttonNumber++) { // see cocoaButton2QtButton() for the 32 value if (!(pmb & (1 << buttonNumber))) m_buttons &= ~cocoaButton2QtButton(buttonNumber); } - NSPoint windowPoint = [self convertPoint: point fromView: nil]; + NSPoint windowPoint = [self.window convertRectFromScreen:NSMakeRect(screenPoint.x, screenPoint.y, 1, 1)].origin; QPoint qtWindowPoint(windowPoint.x, windowPoint.y); - NSWindow *window = [self window]; - NSPoint screenPoint = [window convertRectToScreen:NSMakeRect(point.x, point.y, 0, 0)].origin; QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y)); QWindowSystemInterface::handleMouseEvent(target, mapWindowCoordinates(m_window, target, qtWindowPoint), qtScreenPoint, m_buttons); -- cgit v1.2.3