From d96e939eed606a161e174106925e5cf0904968fa Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Tue, 9 Feb 2010 14:43:02 +0100 Subject: [PATCH] made sure the dragserver doesn't call prepareDrag if the last drag update returned CPDragOperationNone --- AppKit/CPDragServer.j | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/AppKit/CPDragServer.j b/AppKit/CPDragServer.j index 811ec8593..c0438d3af 100644 --- a/AppKit/CPDragServer.j +++ b/AppKit/CPDragServer.j @@ -150,6 +150,10 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0, CGPoint _draggingLocation; id _draggingDestination; + + CGPoint _startDragLocation; + BOOL _shouldSlideBack; + unsigned _dragOperation; } /* @@ -254,10 +258,10 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0, - (void)draggingEndedInPlatformWindow:(CPPlatformWindow)aPlatformWindow globalLocation:(CGPoint)aLocation operation:(CPDragOperation)anOperation { [_draggedView removeFromSuperview]; - + if (![CPPlatform supportsDragAndDrop]) [_draggedWindow orderOut:self]; - + if (_implementedDraggingSourceMethods & CPDraggingSource_draggedImage_endAt_operation_) [_draggingSource draggedImage:[_draggedView image] endedAt:aLocation operation:anOperation]; @@ -296,6 +300,7 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0, _draggingPasteboard = aPasteboard || [CPPasteboard pasteboardWithName:CPDragPboard]; _draggingSource = aSourceObject; _draggingDestination = nil; + _shouldSlideBack = slideBack; // The offset is based on the distance from where we want the view to be initially from where the mouse is initially // Hence the use of mouseDownEvent's location and view's location in global coordinates. @@ -320,9 +325,10 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0, var mouseLocation = [CPEvent mouseLocation]; // Place it where the mouse pointer is. - [_draggedWindow setFrameOrigin:_CGPointMake(mouseLocation.x - _draggingOffset.width, mouseLocation.y - _draggingOffset.height)]; + _startDragLocation = _CGPointMake(mouseLocation.x - _draggingOffset.width, mouseLocation.y - _draggingOffset.height); + [_draggedWindow setFrameOrigin:_startDragLocation]; [_draggedWindow setFrameSize:[aView frame].size]; - + [[_draggedWindow contentView] addSubview:aView]; _implementedDraggingSourceMethods = 0; @@ -385,15 +391,18 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0, if (type === CPLeftMouseUp) { - [self performDragOperationInPlatformWindow:platformWindow]; - [self draggingEndedInPlatformWindow:platformWindow globalLocation:platformWindowLocation operation:CPDragOperationNone]; - + // Make sure we do not finalize (cancel) the drag if the last drag update was disallowed + if (_dragOperation !== CPDragOperationNone) + [self performDragOperationInPlatformWindow:platformWindow]; + + [self draggingEndedInPlatformWindow:platformWindow globalLocation:platformWindowLocation operation:_dragOperation]; + // Stop tracking events. return; } [self draggingSourceUpdatedWithGlobalLocation:platformWindowLocation]; - [self draggingUpdatedInPlatformWindow:platformWindow location:platformWindowLocation]; + _dragOperation = [self draggingUpdatedInPlatformWindow:platformWindow location:platformWindowLocation]; // If we're not a mouse up, then we're going to want to grab the next event. [CPApp setTarget:self selector:@selector(trackDragging:)