Cocoa: Update deprecated dragging session APIs

Change-Id: I06e2dd3861c4bc5d85421ac71daf188732279e77
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
This commit is contained in:
Gabriel de Dietrich 2016-08-05 11:41:47 -07:00
parent 23ea54d861
commit 4c002a8343

View File

@ -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 sources
@ -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);