--- old/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java 2013-01-24 19:25:37.000000000 +0400 +++ new/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java 2013-01-24 19:25:37.000000000 +0400 @@ -98,28 +98,16 @@ Point componentOffset = new Point(); ComponentPeer peer = component.getPeer(); - // For a lightweight component traverse up the hierarchy to the first heavyweight - // which will be used as the ComponentModel for the native drag source. - if (component.isLightweight()) { - Point loc = component.getLocation(); - componentOffset.translate(loc.x, loc.y); - - for (Component parent = component.getParent(); parent != null; parent = parent.getParent()) { - if (parent.isLightweight() == false) { - peer = parent.getPeer(); - break; - } - loc = parent.getLocation(); - componentOffset.translate(loc.x, loc.y); - } + // For a component traverse up the hierarchy to the root + Point loc = new Point(); + for (Component loopComponent = component; loopComponent != null; loopComponent = loopComponent.getParent()) { + peer = loopComponent.getPeer(); + componentOffset.translate(loc.x, loc.y); + loc = loopComponent.getLocation(); } - // Make sure the drop target is a ComponentModel: - if (!(peer instanceof LWComponentPeer)) - throw new IllegalArgumentException("DragSource's peer must be a ComponentModel."); - - // Get model pointer (CButton.m and such) and its native peer: + //Get a pointer to a native window LWComponentPeer model = (LWComponentPeer) peer; CPlatformWindow platformWindow = (CPlatformWindow) model.getPlatformWindow(); long nativeWindowPtr = platformWindow.getNSWindowPtr(); --- old/src/macosx/native/sun/awt/CDragSource.m 2013-01-24 19:25:38.000000000 +0400 +++ new/src/macosx/native/sun/awt/CDragSource.m 2013-01-24 19:25:38.000000000 +0400 @@ -443,9 +443,9 @@ NSGraphicsContext* graphicsContext = [NSGraphicsContext graphicsContextWithWindow:window]; // Convert mouse coordinates to NS: - NSPoint location = NSMakePoint(fDragPos.x, fDragPos.y); - NSPoint eventLocation = [fView convertPoint:location toView:nil]; - + NSPoint eventLocation = [fView convertPoint:NSMakePoint(fDragPos.x, fDragPos.y) toView:nil]; + eventLocation.y = [[fView window] frame].size.height - eventLocation.y; + // Convert fTriggerEventTimeStamp to NS - AWTEvent.h defines UTC(nsEvent) as ((jlong)[event timestamp] * 1000): NSTimeInterval timeStamp = fTriggerEventTimeStamp / 1000; @@ -497,12 +497,9 @@ NSImage* dragImage = fDragImage; // Get drag origin and offset: - NSPoint dragOrigin; - dragOrigin.x = fDragPos.x; - dragOrigin.y = fDragPos.y; - dragOrigin = [view convertPoint:[dragEvent locationInWindow] fromView:nil]; + NSPoint dragOrigin = [dragEvent locationInWindow]; dragOrigin.x += fDragImageOffset.x; - dragOrigin.y += [dragImage size].height + fDragImageOffset.y; + dragOrigin.y -= fDragImageOffset.y + [dragImage size].height; // Drag offset values don't seem to matter: NSSize dragOffset = NSMakeSize(0, 0); @@ -516,7 +513,6 @@ DLog5(@" - drag image: %f, %f (%f x %f)", fDragImageOffset.x, fDragImageOffset.y, [dragImage size].width, [dragImage size].height); DLog3(@" - event point (window) %f, %f", [dragEvent locationInWindow].x, [dragEvent locationInWindow].y); DLog3(@" - drag point (view) %f, %f", dragOrigin.x, dragOrigin.y); - // Set up the fDragKeyModifier, so we know if the operation has changed // Set up the fDragMouseModifier, so we can |= it later (since CoreDrag doesn't tell us mouse states during a drag) fDragKeyModifiers = [DnDUtilities extractJavaExtKeyModifiersFromJavaExtModifiers:fModifiers];