diff --git a/src/macosx/classes/sun/lwawt/LWComponentPeer.java b/src/macosx/classes/sun/lwawt/LWComponentPeer.java index 02040f3a67a22a8b842a08aaf380c154d743391c..a7b15e07c9640f77f985207b6443f5ebbeacf9f9 100644 --- a/src/macosx/classes/sun/lwawt/LWComponentPeer.java +++ b/src/macosx/classes/sun/lwawt/LWComponentPeer.java @@ -985,16 +985,23 @@ public abstract class LWComponentPeer // DropTargetPeer Method @Override public void addDropTarget(DropTarget dt) { - synchronized (dropTargetLock){ - // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only - // if it's the first (or last) one for the component. Otherwise this call is a no-op. - if (++fNumDropTargets == 1) { - // Having a non-null drop target would be an error but let's check just in case: - if (fDropTarget != null) - System.err.println("CComponent.addDropTarget(): current drop target is non-null."); - - // Create a new drop target: - fDropTarget = CDropTarget.createDropTarget(dt, target, this); + LWWindowPeer winPeer = getWindowPeerOrSelf(); + if (winPeer != null && winPeer != this) { + // We need to register the DropTarget in the + // peer of the window ancestor of the component + winPeer.addDropTarget(dt); + } else { + synchronized (dropTargetLock) { + // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only + // if it's the first (or last) one for the component. Otherwise this call is a no-op. + if (++fNumDropTargets == 1) { + // Having a non-null drop target would be an error but let's check just in case: + if (fDropTarget != null) + System.err.println("CComponent.addDropTarget(): current drop target is non-null."); + + // Create a new drop target: + fDropTarget = CDropTarget.createDropTarget(dt, target, this); + } } } } @@ -1002,17 +1009,24 @@ public abstract class LWComponentPeer // DropTargetPeer Method @Override public void removeDropTarget(DropTarget dt) { - synchronized (dropTargetLock){ - // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only - // if it's the first (or last) one for the component. Otherwise this call is a no-op. - if (--fNumDropTargets == 0) { - // Having a null drop target would be an error but let's check just in case: - if (fDropTarget != null) { - // Dispose of the drop target: - fDropTarget.dispose(); - fDropTarget = null; - } else - System.err.println("CComponent.removeDropTarget(): current drop target is null."); + LWWindowPeer winPeer = getWindowPeerOrSelf(); + if (winPeer != null && winPeer != this) { + // We need to unregister the DropTarget in the + // peer of the window ancestor of the component + winPeer.removeDropTarget(dt); + } else { + synchronized (dropTargetLock){ + // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only + // if it's the first (or last) one for the component. Otherwise this call is a no-op. + if (--fNumDropTargets == 0) { + // Having a null drop target would be an error but let's check just in case: + if (fDropTarget != null) { + // Dispose of the drop target: + fDropTarget.dispose(); + fDropTarget = null; + } else + System.err.println("CComponent.removeDropTarget(): current drop target is null."); + } } } } diff --git a/src/macosx/native/sun/awt/CDropTarget.m b/src/macosx/native/sun/awt/CDropTarget.m index 4453d2f4022db2b528303a008979191abe069ed1..60cd7818254d4e8c17fa4e9fb2f1f5920c7a827a 100644 --- a/src/macosx/native/sun/awt/CDropTarget.m +++ b/src/macosx/native/sun/awt/CDropTarget.m @@ -648,6 +648,10 @@ extern JNFClassInfo jc_CDropTargetContextPeer; if (sDraggingError == FALSE) { sDraggingLocation = [sender draggingLocation]; NSPoint javaLocation = [fView convertPoint:sDraggingLocation fromView:nil]; + // The y coordinate that comes in the NSDraggingInfo seems to be reversed - probably + // has to do something with the type of view it comes to. + // This is the earliest place where we can correct it. + javaLocation.y = fView.window.frame.size.height - javaLocation.y; jint actions = [DnDUtilities mapNSDragOperationMaskToJava:[sender draggingSourceOperationMask]]; jint dropAction = sJavaDropOperation;